EWS: Calendar Sharing Invitation and Extended Prop

2019-07-08 05:57发布

问题:

Ok, so far the best information I have gotten regarding this topic was on this thread: EWS-API-Create-Calendar-and-Share-with-reviewer-permissions. I tried asking this question on that thread but I actually posted it as an answer so it was removed by the admins (my bad!)

DISCLAIMER: I am a sysadmin by trade and moonlight in development...so please excuse any misuse of terminology or confusions in verbage.

Also, I'm working in C# here fyi.

I have read the message protocol specs from microsoft and understand that certain extended properties need to be created on a message item to properly create a sharing invitation object I understand from the post mentioned above, I can create a message object with extended properties (SetExtendedProperty(extprop,value) to be exact). I understand that I must manually create the extended properties I'm setting using new ExtendedProperty() and populate the correct Parent GUID, HexID, and Datatype on each property. From what I can gather this is more or less a "workaround" due to there being no inherent sharing object management capabilities built into the API...

But I've ran into a snag and need some clarification...

I wanted to manually create a sharing invite (via the client, the "user" way), and then attach to the message in the Sent Items box of the user who sent the invitation. I wanted to enumerate all possible properties relative to what I need to use to build a similar object so I could use it as a template and compare my objects properties against the original invite. I can get the message fine and find many properties, but not any "special" ones. The only thing I can find that differentiate the message item is the fact that it's IPM.Sharing Item Class and that it has an attachment of sharing_metadata.xml.

But am I correct in assuming now that we can create sharing invites via the API through using extended properties, that doesn't necessarily mean we can read those properties via the API??

Everything I tried to enumerate extended properties doesn't seem to work, and always returns nothing instead of an array of extended properties. Maybe I'm not doing it right, but I wanted to ask the question before spending countless more hours trying to achieve something that's not possible.

So if I can't properly enumerate the extended properties, is there a possibiltiy of using something like ExFolders or MFCMAPI or something to get those properties???

Any thoughts/suggestions/critisisms?

Thanks!

UPDATE:

Heres the function I'm playing with to try and create a sharing invite for a users calendar folder...I've commented where I'm stuck and what I'm not completely wrapping my head around:

    public void CreateCalendarSharingRequest(string folderID, string owner, string sharedToUser)
    {
        // LOAD OUR CUSTOM PROPERTIES
        Guid PropertySetSharing = new Guid("{00062040-0000-0000-C000-000000000046}");
        Guid PropertySetInternetHeaders = new Guid("{00020386-0000-0000-C000-000000000046}");

        // Sharing Properties
        ExtendedPropertyDefinition PidLidSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.CLSID);
        ExtendedPropertyDefinition PidLidSharingProvidorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A02, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingFlavor = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A18, MapiPropertyType.Integer);
        ExtendedPropertyDefinition PidLidSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A48, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A06, MapiPropertyType.String);
        ExtendedPropertyDefinition PidTagMessageClass = new ExtendedPropertyDefinition(0x001A, MapiPropertyType.String);
        ExtendedPropertyDefinition PidTagNormalizedSubject = new ExtendedPropertyDefinition(0x0E1D, MapiPropertyType.String);
        ExtendedPropertyDefinition PidTagSubjectPrefix = new ExtendedPropertyDefinition(0x003D, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingCapabilities = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A17, MapiPropertyType.Integer);
        ExtendedPropertyDefinition PidLidSharingInitiatorEntryId = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A09, MapiPropertyType.Binary);
        ExtendedPropertyDefinition PidLidSharingConfigurationUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A24, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingInitiatorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A07, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingInitiatorSMTP = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A08, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingLocalType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A14, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingRemoteType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A1D, MapiPropertyType.String);
        ExtendedPropertyDefinition PidLidSharingRemoteName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A05, MapiPropertyType.String);

        // Internet Header Properties
        ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "Content-Class", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingCapabilities = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Capabilities", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingConfigUrl = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Config-Url", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingFlavor = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Flavor", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingLocalType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Local-Type", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingRemoteName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Name", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Store-Uid", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingRemoteType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Type", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Uid", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-Guid", MapiPropertyType.String);
        ExtendedPropertyDefinition PidNameXSharingProviderName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-Name", MapiPropertyType.String);

          // Bind to the web services and currently selected folder
        // Get the current list of delegates for this folder
        ExchangeService service = GetExchangeService();

        // Create a new message
        EmailMessage invitationRequest = new EmailMessage(service);
        invitationRequest.Subject = "I'd like to share my calendar with you";
        invitationRequest.Body = "Send by Exchange Administrator on behalf of user";
        invitationRequest.From = GetSMTPAddress(owner);
        invitationRequest.ItemClass = "IPM.Sharing";
        invitationRequest.SetExtendedProperty(PidNameContentClass, "Sharing");
        invitationRequest.SetExtendedProperty(PidTagMessageClass, "IPM.Sharing");
        invitationRequest.SetExtendedProperty(PidLidSharingFlavor,0x20310); /* Indicates Invitation for a special folder */
        invitationRequest.SetExtendedProperty(PidNameXSharingFlavor, "20310"); /* Text representation of SharingFlavor value */
        invitationRequest.SetExtendedProperty(PidLidSharingProviderGuid, PropertySetSharing.ToString());
        invitationRequest.SetExtendedProperty(PidNameXSharingProviderGuid, PropertySetSharing.ToString());
        invitationRequest.SetExtendedProperty(PidLidSharingCapabilities, 0x40290); /* value for Special Folders */
        invitationRequest.SetExtendedProperty(PidNameXSharingCapabilities, "40290"); /* Test representation of SharingCapabilities value */

        // THIS IS WHERE IM STUCK - I understand how to set some of the properties like above, but then
        // it starts needing the entryID properties for the folder being shared, etc...and I'm not entirely
        // sure which properties I have to set and how many can/will be autopopulated by the transport provider
        // All i wanna do is send an invite message for sharing the calendar folder from one user to another!

        // Add recipient info

        //invitationRequest.ToRecipients.Add(sharedToUser);
        //invitationRequest.SendAndSaveCopy();

    }

回答1:

Well I figured it out...but it wasn't easy. If your interested in how I was able to get a sharing invitation sent through Exchange 2010's EWS API 1.2, you can read about it here