Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EWS API - Create calendar and share with reviewer permissions

I'm having some trouble on creating and share a calendar with review permissions using Exchange Webservice API .NET.

At the moment this is my code:

Folder addCalendar = new Folder(service);
addCalendar.DisplayName = name;
addCalendar.FolderClass = "IPF.Appointment";
var perm = new FolderPermission(new UserId("[email protected]"),
                            FolderPermissionLevel.Reviewer);
addCalendar.Permissions.Add(perm);
addCalendar.Save(WellKnownFolderName.MsgFolderRoot);

The calendar is created, in my account I can see the calendar and the user '[email protected]' has the correct permissions.

The problem is: The calendar doesn't show at the reviewer's account.

like image 953
Canastro Avatar asked Sep 21 '11 16:09

Canastro


2 Answers

You have to do two things:

Set the appropiate permissions:

var folder = Folder.Bind(service, WellKnownFolderName.Calendar);
folder.Permissions.Add(new FolderPermission("[email protected]", 
    FolderPermissionLevel.Reviewer));
folder.Update();

Then, send an invitation message. Now, this is the hard part. The message format is specifified in [MS-OXSHARE]: Sharing Message Object Protocol Specification. The extended properties are defined in [MS-OXPROPS]: Exchange Server Protocols Master Property List. You need to create a message according to that specification and send it to the recipient.

EDITED:

To set the sharing properties on the element, use extended properties.

First, define the properties. For example, the PidLidSharingProviderGuidProperty is defined as follows:

private static readonly Guid PropertySetSharing = new Guid("{00062040-0000-0000-C000-000000000046}");
private static readonly ExtendedPropertyDefinition PidLidSharingProviderGuidProperty = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.CLSID);      
private static readonly ExtendedPropertyDefinition ConversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);

You can then set the property on a new item using the SetExtendedProperty method:

item.SetExtendedProperty(PidLidSharingProviderGuidProperty, "somevalue");
like image 96
Henning Krause Avatar answered Sep 18 '22 23:09

Henning Krause


I figured out how to programmatically send a sharing invitation within an organization through EWS. May not answer all your questions, but it's a good start to understanding how in-depth you gotta get to actually do it. Heres the link

like image 24
WillCodeForFood Avatar answered Sep 18 '22 23:09

WillCodeForFood