6

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("reviewer@test.com"),
                            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 'reviewer@test.com' has the correct permissions.

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

Canastro
  • 2,979
  • 30
  • 39
  • What do you mean with "Doesn't show at the reviewer's account"? Can the reviewer open the calendar using Outlook? File -> Open -> Other users Folder. – Henning Krause Sep 21 '11 at 18:06
  • Well I tried with the reviewer account open his calendar and I didn't succeed, but anyway I wanted to share the calendar with the EWS API without the need of using outlook to complete the process. – Canastro Sep 22 '11 at 09:09
  • Do I unerstand you correctly that you want to create a sharing invitation message? The one which Outlook creates when you right click on your calendar and select Share -> Share calendar? – Henning Krause Sep 26 '11 at 17:10
  • Correct, that's exactly what I want to do! – Canastro Sep 26 '11 at 20:39

2 Answers2

4

You have to do two things:

Set the appropiate permissions:

var folder = Folder.Bind(service, WellKnownFolderName.Calendar);
folder.Permissions.Add(new FolderPermission("someone@yourcompany.com", 
    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");
Sergey Litvinov
  • 7,408
  • 5
  • 46
  • 67
Henning Krause
  • 5,302
  • 3
  • 24
  • 37
3

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