I'm using EWS to read and extract images from an email served by exchange 2013. using the code below which is working great when the images are attached as actual attachments.. The problem arises when images come through as inline attachments.
The EWS .Hasattachments does not return true for inline attachments.. It seems silly that this has not been thought of.. Reading the article below there appears to be a work around but I just wondering what is the best, most efficient way to retrieve both regular & inline image attachments and save them to a directory.
if (mail.HasAttachments && mail.Attachments[0] is FileAttachment)
{
int count = 0;
foreach (Attachment attachment in mail.Attachments)
{
if (attachment is FileAttachment && attachment.ContentType == "image/jpeg")
{
Console.WriteLine(attachment.Name);
FileAttachment fileAttachment = attachment as FileAttachment;
string imagename = s + "-" + System.DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".jpg";
/* download attachment to folder */
fileAttachment.Load(imageLocation + "\\Images\\" + imagename);
}