Month: May 2012

Get Lync Online Meetings’ Information using the EWS Managed API


In this article we will learn how to be able to use Exchange Web Services (EWS) via the EWS Managed API to access an Exchange Mailbox calendar and view all information for the Online Lync meetings.

The examples are written to work with the Exchange Online and Lync Online from the Office365 suite and within a private cloud or on-premise deployment of Lync 2010 and Exchange 2007 or Exchange 2010.

When a user schedules an Online meeting in Outlook 2007/2010 the meeting and Lync information associated with that meeting are stored in a number of MAPI properties on the Appointment Item.

You can use these information further to do many tasks i.e. to join a conference meeting using the browser or in any other way like the Lync SDK, also you could use these information to put it in a calendar.

EWS Managed API

The Microsoft Exchange Web Services (EWS) Managed API provides an intuitive interface for developing client applications that use Exchange Web Services. The EWS Managed API provides unified access to Microsoft Exchange Server resources, while using Microsoft Outlook–compatible business logic. The EWS Managed API uses EWS SOAP messages to communicate with the Exchange Client Access server.

Microsoft encourage Microsoft .NET Framework developers to use the EWS Managed API instead of auto generated proxies to develop against Exchange Web Services. The EWS Managed API object model is significantly easier to use than autogenerated proxy object models.

Prerequisite

  • Microsoft Visual Studio
  • C# Language
  • EWS Managed API
  • Exchange Server with known credential

Sample Code

Add reference to the Microsoft.Exchange.WebServices

using Microsoft.Exchange.WebServices.Data;

Connect to Exchange Web Services as user1 at YourDomain.com and select the version of the exchange you are using

var service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("user1@YourDomain.com");

Select the folder that you want to get its items. In this case should select the calendar to get the online meetings

var calendarFolder = new FolderId(WellKnownFolderName.Calendar);

Choose the appropriate period to get its meetings and the number of items you want to get

var calendarView = new CalendarView(DateTime.Now, DateTime.Now.AddMonths(1), 1000);
var UCOpenedConferenceID = 
    new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings,
                                  "UCOpenedConferenceID",
                                   MapiPropertyType.String);
var OnlineMeetingExternalLink =
    new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings,
                                  "OnlineMeetingExternalLink",
                                   MapiPropertyType.String);

Start getting the items of the folder

PropertySet iDPropertySet =
    new PropertySet(BasePropertySet.IdOnly) {UCOpenedConferenceID};
calendarView.PropertySet = iDPropertySet;
var lyncMeetings = new List();
var appoResult = service.FindAppointments(calendarFolder, calendarView);
foreach (var appointment in appoResult)
{
    object UCconfId = null;
    if(appointment.TryGetProperty(UCOpenedConferenceID, out UCconfId))
        lyncMeetings.Add(appointment);
}

Start getting the details of each item

var detailPropertySet =
new PropertySet(BasePropertySet.FirstClassProperties) { OnlineMeetingExternalLink };
service.LoadPropertiesForItems(lyncMeetings, detailPropertySet);
foreach (Appointment appointment in lyncMeetings)
{
    object lyncMeetingUrl = null;
    appointment.TryGetProperty(OnlineMeetingExternalLink, out lyncMeetingUrl);
}

Download EWS API