Search code examples
c#outlookexchangewebservicesskypelync

Using Microsoft's EWS to create online Lync/Skype meeting


Anybody knows how to create meeting request with online conference(Lync/Skype) using EWS?

So my approach is first getting an online and regular meeting created via Outlook and then simulate the creation of event with the same property.

Here is my code snippet for getting the meeting (calendarView is already initialized with start date, end date etc.):

ExtendedPropertyDefinition extendedOnlineMeetingProperty =
                new ExtendedPropertyDefinition(new Guid("{00062008-0000-0000-c000-000000000046}"), 34112,
                    MapiPropertyType.Integer);

var properties = new PropertySet(
            ItemSchema.Id,
            AppointmentSchema.ICalUid,
            ItemSchema.Subject,
            AppointmentSchema.Start,
            AppointmentSchema.End,
            AppointmentSchema.Organizer,
            AppointmentSchema.Location,
            AppointmentSchema.LegacyFreeBusyStatus,
            AppointmentSchema.IsCancelled,
            AppointmentSchema.ICalRecurrenceId,
            AppointmentSchema.MyResponseType, // Mandatory Meeting.MyResponseType can be retrieved without a search in the participant list
            ItemSchema.LastModifiedTime,
            AppointmentSchema.IsOnlineMeeting,
            AppointmentSchema.IsMeeting,
            ItemSchema.DisplayTo) { };

 properties.Add(extendedOnlineMeetingProperty);


var activeResults = service.FindAppointments(WellKnownFolderName.Calendar, calendarView).ToList();
    if (activeResults.Count > 0)
    {
        service.LoadPropertiesForItems(activeResults, properties);
    }

I got the property IsOnlineMeeting with the correct bool value (tested - created online and regular meeting with Outlook) in variable activeResults but I do not understand where to get conference link and other Lync/Skype properties needed for joining a conference.

Also I am not sure where and how to assign the values of Lync/Skype conference URL and other properties.

Sometimes I ask myself if it's worth it to developed some app based on MS products since their documentation suck.


Solution

  • After one week of cursing MS I have found a solution. Using the tool MFCMAPI you can check what property and their values your item in mailbox have.

    1. download the program link
    2. build and run it
    3. Session - Logon - choose your mail profile - pick the mailbox and double click
    4. actions - open special folder - calendar - double click on calendar
    5. open the item with online S4B/Lync conference
    6. the UC* properties are the one I was looking for.

    If you open the property you can see something like this on the top:

    ag: 0x8096001E
    Type: PT_STRING8
    DASL: http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/UCMeetingSetting
    Named Prop Name: UCMeetingSetting
    Named Prop Guid: {00020329-0000-0000-C000-000000000046} = PS_PUBLIC_STRINGS
    

    So my definition of the extended property was wrong. It is not only one property but actually you need all 7 of them.

    So the definition should be:

    private static ExtendedPropertyDefinition CreateOnlineMeetingProperty()
            {
                ExtendedPropertyDefinition extendedUCMeetingSetting =
                    new ExtendedPropertyDefinition(new Guid("{00020329-0000-0000-C000-000000000046}"), "UCMeetingSetting",
                        MapiPropertyType.String);
    
                return extendedUCMeetingSetting;
            }
    

    With the correct extended definition you can get the values from the item easily.

    1. accessing the Value of ExtendedProperties
    2. Calling TryGetProperty
    var activeResults = service.FindAppointments(new
    FolderId(WellKnownFolderName.Calendar, resource.Email),calendarView).ToList();
    
    service.LoadPropertiesForItems(activeResults, properties);
    
    foreach (Appointment result in activeResults)
    {
    // 1.
    var b = result.ExtendedProperties[1].Value;
    // 2.
    string UCMeetingSetting;
    result.TryGetProperty(extendedUCMeetingSetting, out UCMeetingSetting);
    }
    

    using steps above you can get whatever extended property you want, not only Unified Communications (UC) properties.