use the security assist Random Password tool.
on the bindings panel, click the plus button and select WebAssist -> Random Password.
then add a Set Session variable behavior, On the server behaviors panel, click the plus button and select eCart -> General -> Set Session Value
set the trigger to before page load, set the name to something like VoucherCode, click the lightning bolt next to value and select the random password binding.
use this session in the database and in the email to send the voucher code.