A complete script to send emails with attachments using the Web API