Skip to main content

Cloud

Speed up Development with Exchange Web Services Managed API

We’ve all experienced it before, those “Wow, I can’t believe it’s that easy” moments. Exchange Web Services Managed API makes sending emails, creating appointments, querying folders/calendars, and generating meeting requests extremely simple.When it comes to programmatically duplicating Outlook functionality (given Exchange is running the show), the Exchange Web Services Managed API is definitely worth looking into.

There’s some good documentation online, but the object model is easy enough to get started with. Instead of writing a blog that highlights the features of this API, I’ll instead show you how I put it to use for areal use case.

I was working on a project that required an Outlook meeting request to be sent to a user programmatically.My first approach was to use the System.Net.Mail namespace to utilize the SmtpClient object.This works great for sending basic email messages, but did not deliver the ’round-robin’ functionality I was looking for.For example, the recipient of the SmtpClient’s meeting request did not have the ability to Accept/Decline or purpose a new time to the organizer (refer to this blog post for the explanation).Another downside is the requirement of having to create proper formatted vCalendar as well as alternate views.

Since the organization was using Exchange 2010 (ewsm 1.1 will also work with Exchange 2007), I opted for the Exchange Web Services Managed API.This made for less code that was easier to read and worked exactly as I needed it to.

Here’s a quick demonstration on how to create an Outlook meeting request when using the Exchange Web Services Managed API.

After downloading the API, add a reference to the assembly.

Page directives

By default, the ExchangeService object will use the credentials of the logged in user to establish a connection, so it is not necessary to create a new ‘NetworkCredential’ object (I’ll get to why took this route in a moment).In some cases this might be just what you need.In my situation I chose to use the credentials of a service account and which has the role of “ApplicationImpersonation”.This way, when the appointment is created, it will be appear on the impersonated user’s calendar first.

From the point of view of any attendees, it will look just like the meeting request was generated from the impersonated user’s Outlook client.The options to Accept/Decline with message back to the organizer will now be available because all parties are referencing the same UID.It is in the new ‘NetworkCredential’ object that I’m using the service account.This account has permission to impersonate all users within the organization.This method can be modified to pass in a string of a user’s email address to be impersonated.

Send Email Method with no Parameters

In Conclusion

The Exchange Web Services Managed API is something I wish I would have discovered much sooner.It’s a slick way to send everything from simple email messages to meeting requests and can encapsulate most of the functionality of an Exchange client.

Useful Links

http://msdn.microsoft.com/en-us/library/dd635461.aspx

http://msdn.microsoft.com/en-us/library/dd633626(v=exchg.80).aspx

http://msdn.microsoft.com/en-us/library/dd633907(v=EXCHG.80).aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Steven Mierop

As a Lead Technical Consultant at Perficient, I've had the pleasure of designing and delivering custom solutions on SharePoint 2007-2013. I have a strong passion for web application development and the .NET framework. Over the past three years, I have implemented a variety of SharePoint and .NET solutions for clients in a wide range of Industries such as Health Care, Insurance, Pharmaceutical, and Publishing.

More from this Author

Follow Us