Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Now you're ready to implement the four functions I listed at the beginning of the chapter:
Before you can do anything else, you'll need to connect to the Exchange server. I'll start with that feature. You will first add the logic in the ExchangeDataContext class that calls the autodiscover process. Then you'll implement the click event in the code-behind class.
Go to the ExchangeDataContext class and add the code shown in Listing 12-1 to the class definition.
Listing 12-1. Connecting to the Exchange Server
private ExchangeService _service;
public ExchangeDataContext(string emailAddress, string password)
{
_service = GetBinding(emailAddress, password);
}
public ExchangeService GetService()
{
return _service;
}
static ExchangeService GetBinding(string emailAddress, string password)
{
// Create the binding.
ExchangeService service =
new ExchangeService(ExchangeVersion.Exchange2010_SP1);
// Define credentials.
service.Credentials = new WebCredentials(emailAddress, password);
// Use the AutodiscoverUrl method to locate the service endpoint.
try
{
service.AutodiscoverUrl(emailAddress, RedirectionUrlValidationCallback);