Exchange Web Services

I’ve been tinkering around with the Exchange Managed API (ver 1.1) for a few days and have to say it’s FAR easier than I expected (at least for my simple tasks). I know it’s an old technology, but have to say simple things amuse me.

Although I’ll be tinkering with Exchange 2010 soon, I’ve been doing some initial work against Exchange Online and so far, so good. In this day and age I *shouldn’t* be surprised when something is quick and easy (particularly high level language with high level app) but I am.

I was expecting I’d be able to point Visual Studio to a WSDL location such as http://blah blah/EWS/exchange.wsdl (or whatever) but so far I’ve had to initialise the connection using code.

 

eg.

 

ExchangeService ConnectMeDammit

{

// specify Exchange version….

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

 

      // setup credentials for login.

service.Credentials = new WebCredentials(“faulkner@madeup.onmicrosoft.com“, “mypassword”);

// try and detect server via email address.

service.AutodiscoverUrl(“faulkner@madeup.onmicrosoft.com“, RedirectionUrlValidationCallback);

  return service;

}

 

 

and hey preso… have a service connection which then allows a bunch of functionality, far more than I need.

 

Send an email…. no problem:

EmailMessage message = new EmailMessage( service );

message.Subject = “super secret subject”;

message.Body = new MessageBody(“Do I have a nice body?”);

message.ToRecipients.Add(  “myemailaddress@gmail.com“);

message.SendAndSaveCopy();

 

Done!  

Sending, querying folders, deleting all available. 

 

Advertisements