Save attachments from embedded email message? RRS feed

  • Question

  • How do I use EWS to save the file attachments which are included in an embedded email (ie. an attached email message)?

     I have an email that contains an embedded email which has the actual attachment (document).  I can grab the itemAttachment, but can only get the subject, body, etc...  I need to get the actual file attachment saved out to disk.  Also it would be nice if I could recursively to through these (like the AttachmentCollection), but not sure how to do that either.


    if (attachment is ItemAttachment)
    	Console.WriteLine("Attachment is ItemAttachment: " + attachment.Name);
    	ItemAttachment itemAttachment = item.Attachments[0] as ItemAttachment;
    	if (itemAttachment != null)
    		Console.WriteLine("Embedded ContentId: " + itemAttachment.ContentId);
    		Console.WriteLine("Embedded ContentType: " + itemAttachment.ContentType); 
    		Console.WriteLine("Embedded IsInline: " + itemAttachment.IsInline); 
    		Console.WriteLine("Embedded Subject: " + itemAttachment.Item.Subject);
    		Console.WriteLine("Embedded Body: " + itemAttachment.Item.Body);

    How do I get the embedded attachments?


    Best Regards,

    Tuesday, January 10, 2012 9:35 PM