Access to email exchange from c#

To use this code, you need to install , this will create a dll, that you need to import to the project

 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

 service.Credentials = new NetworkCredential(user, password, domain);

 service.Url = new Uri("https://domain/EWS/Exchange.asmx");

 Mailbox mb = new Mailbox(email_to_access);
 FolderId fid1 = new FolderId(WellKnownFolderName.Inbox, mb);

 //reads the emails
 FindItemsResults <Item> findResults = service.FindItems(fid1, new ItemView(50));

 foreach (Item item in findResults.Items)
  EmailMessage m = (EmailMessage)item;
  if (!m.IsRead)
   //Set Isread.
   m.IsRead = true;

0 comentários:

Enviar um comentário