Posted By

poxet on 12/21/10


Tagged

sent exchange


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dotNetkow


Get sent messages from exchange


 / Published in: C#
 

Use the exchange SOAP api to retrieve sent messages.

  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  

You need to login to post a comment.