Fixing exception when sending an email