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

Advertisements

12 comments

  1. Hello,
    i want to create a meeting using EWS managed api 2.0 ant the get the meeting’s url created to send it to others users. I use this code to create a meeting
    // Create the appointment.
    Appointment appointment = new Appointment(service);

    // Set properties on the appointment. Add two required attendees and one optional attendee.
    appointment.Subject = “Status Meeting”;
    appointment.Body = “The purpose of this meeting is to discuss status.”;
    appointment.Start = new DateTime(2009, 3, 1, 9, 0, 0);
    appointment.End = appointment.Start.AddHours(2);
    appointment.Location = “Conf Room”;
    appointment.RequiredAttendees.Add(“user1@contoso.com”);
    appointment.RequiredAttendees.Add(“user2@contoso.com”);
    appointment.OptionalAttendees.Add(“user3@contoso.com”);

    // Send the meeting request to all attendees and save a copy in the Sent Items folder.
    appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

    adding this line at end
    string OnlineMeetingUrl = appointment.JoinOnlineMeetingUrl;

    i got this error” You must load or assign this property before you can read its value”.

    Any idea how to solve this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s