I am using EWS 1.2 to search my mailbox for emails with attachments and I am binding EmailMessage object to the EWS object. This is working fine but not detecting .msg files (outlook message files):
ItemView mailview = new ItemView (12);
FindItemsResults<Item> resultmail;
resultmail = Service.FindItems(WellKnownFolderName.Inbox, mailview);
foreach (Item item in resultmail.Items)
{
EmailMessage email = EmailMessage.Bind(Service, item.Id,
new PropertySet(BasePropertySet.FirstClassProperties,
ItemSchema.Attachments));
if (email.HasAttachments)
{
foreach (var attachment in email.Attachments)
{
if (attachment is FileAttachment)
{
Console.WriteLine("email has : " + email.Attachments.Count
+ "attachement(s)" + "\n");
Console.WriteLine("attachment name:" + attachment.Name);
}
}
}
}