Get sent messages from exchange


/ Published in: C#
Save to your folder(s)

Use the exchange SOAP api to retrieve sent messages.


Copy this code and paste it in your HTML
  1. using Microsoft.Exchange.WebServices.Data;
  2.  
  3. internal static ExchangeService ExchangeService
  4. {
  5. get
  6. {
  7. var exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); //Or ExchangeVersion.Exchange2010
  8.  
  9. //Use NetworkCredential in the ExchangeServiceBase namespace (If this line is excluded, current user will be used)
  10. exchangeService.Credentials = new System.Net.NetworkCredential("userName", "password", "domain");
  11.  
  12. //URL to the exchange service
  13. exchangeService.AutodiscoverUrl("emailAddress"); //Use email address to find uri
  14. //exchangeService.Url = new Uri(exchangeServiceUrl); //set explicit path to uri
  15.  
  16. return exchangeService;
  17. }
  18. }
  19.  
  20. public static FindItemsResults<Item> GetSentMessages(int pageSize, int offset, out int totalCount)
  21. {
  22. var findResults = ExchangeService.FindItems(WellKnownFolderName.SentItems, new ItemView(pageSize, offset));
  23. totalCount = findResults.TotalCount;
  24. return findResults;
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.