In a previous article on sending email with Exchange Web Services (EWS) we showed how easy it was to integrate with Exchange and send email. If you’ve ever wanted to attach a file to an email that your sending, it’s super easy (much faster than the System.Net.Mail method):
//Create an email message and identify the Exchange service EmailMessage message = new EmailMessage(service); //Attach a file - THE MAGIC message.Attachments.AddFileAttachment(@"c:\temp\somefile.jpg"); //Send the email message and save a copy message.SendAndSaveCopy();
That’s it! If you want to see all of the code needed for sending, see Retrieving and Sending Email using Exchange Web Services Managed API 2.0 (c#)