Simulate sending email and fix related bugs
Added support for emailing attachments