Adding Andrew's new emailing code