I use EWS API 1.2 to access mailboxes on our Exchange server. It just works fine, but there is one thing I cannot achieve: receive email attachments.
Im wrote the following lines:
class Program { public static void Main(string[] args) { try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); service.Credentials = new WebCredentials("login","password"); service.AutodiscoverUrl(" mail@domaine.fr "); ItemView view = new ItemView(10); FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10)); if (findResults != null && findResults.Items != null && findResults.Items.Count > 0) foreach (Item item in findResults.Items) { if (item.Attachments != null) { IEnumerator<Attachment> e = item.Attachments.GetEnumerator(); } Console.WriteLine(item.Subject); } else Console.WriteLine("no items"); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); } }
I get all the emails in a verified mailbox, but IEnumerator<Attachment> e = item.Attachments.GetEnumerator(); doesn't seem to see the "attachment".
Do you have any idea what I missed?
Many thanks.
user343081
source share