Return to Snippet

Revision: 37934
at December 21, 2010 03:03 by poxet


Initial Code
using Microsoft.Exchange.WebServices.Data;

internal static ExchangeService ExchangeService
{
    get
    {
        var exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); //Or ExchangeVersion.Exchange2010

        //Use NetworkCredential in the ExchangeServiceBase namespace (If this line is excluded, current user will be used)
        exchangeService.Credentials = new System.Net.NetworkCredential("userName", "password", "domain");

        //URL to the exchange service
        exchangeService.AutodiscoverUrl("emailAddress");        //Use email address to find uri
        //exchangeService.Url = new Uri(exchangeServiceUrl);    //set explicit path to uri

        return exchangeService;
    }
}

public static FindItemsResults<Item> GetSentMessages(int pageSize, int offset, out int totalCount)
{
    var findResults = ExchangeService.FindItems(WellKnownFolderName.SentItems, new ItemView(pageSize, offset));
    totalCount = findResults.TotalCount;
    return findResults;
}

Initial URL

                                

Initial Description
Use the exchange SOAP api to retrieve sent messages.

Initial Title
Get sent messages from exchange

Initial Tags

                                

Initial Language
C#