Updated send email code