none
EWS Managed API - Problems with calendar sharing request RRS feed

  • Question

  • Hello.

    I would like to send a sharing request to a special user to get access to his calendar items. After receiving this message the user can accept or deny my request.
    After 2 days of recherche and coding a small example I'm stuck (as I think) at the correct parameters (ExtendedPropertyDefinition like PidTagMessageClass and so on).

    Please have a look to the following relevant code snippets:


        public void SendMessage()
        {
            byte[] binInitiatorEntryId = Converter.HexStringToByteArray(this.MailboxFunctions.GetIntiatorEntryID(this.Service));

            // This is the Guid of the Sharing Provider in Exchange, and it's value does not change
            Guid PropertySetSharing = new Guid("{AEF00600-0000-0000-C000-000000000046}");

            // Even though I don't think setting this property is mandatory,
            // it just seemed like the right thing to do and it works so I \
            // ain't messin with it!                                       
            byte[] byteSharingProviderGuid = PropertySetSharing.ToByteArray();

            // Create a new message
            EmailMessage invitationRequest = new EmailMessage(this.Service);
            invitationRequest.Subject = "Sharing request: 'Calendar'";
            invitationRequest.Body = "Sent by Exchange Administrator on behalf of user";
            invitationRequest.From = "sender mail adress";
            invitationRequest.Culture = "us-US";
            invitationRequest.Sensitivity = Sensitivity.Normal;
            invitationRequest.Sender = "/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FXDICOHF11SPDLT)/CN=RECIPIENTS/CN=CAA2C1E7A3934797A8258CGG42B337D0-THER";
            invitationRequest.ItemClass = "IPM.Sharing"; /* Constant Required Value [MS-ProtocolSpec] */

            ExtendedPropertyDefinition PidTagMessageClass = new ExtendedPropertyDefinition(0x001A, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidTagMessageClass, "IPM.Sharing"); /* Constant Required Value [MS-ProtocolSpec] */

            ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "Content-Class", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameContentClass, "Sharing");

            ExtendedPropertyDefinition PidTagNormalizedSubject = new ExtendedPropertyDefinition(0x0E1D, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidTagNormalizedSubject, "Sharing request: 'Calendar'");

            ExtendedPropertyDefinition PidTagSubjectPrefix = new ExtendedPropertyDefinition(0x003D, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidTagSubjectPrefix, " ");

            ExtendedPropertyDefinition PidLidSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8243, MapiPropertyType.Binary);
            invitationRequest.SetExtendedProperty(PidLidSharingProviderGuid, byteSharingProviderGuid);

            ExtendedPropertyDefinition PidNameXSharingProviderGuid = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Provider-GUID", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingProviderGuid, "AEF0060000000000C000000000000046");

            ExtendedPropertyDefinition PidLidSharingProviderName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8244, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingProviderName, "Microsoft Exchange");

            ExtendedPropertyDefinition PidNameXSharingProviderName = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Provider-Name", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingProviderName, "Microsoft Exchange");

            ExtendedPropertyDefinition PidLidSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x8245, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingProviderUrl, "h**p://www.microsoft.com/exchange" );

            ExtendedPropertyDefinition PidNameXSharingProviderUrl = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Provider-URL", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingProviderUrl, "h**p://www.microsoft.com/exchange");

            ExtendedPropertyDefinition PidLidSharingConfigurationUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x83D0, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingConfigurationUrl, " ");

            ExtendedPropertyDefinition PidNameXSharingConfigUrl = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Config-Url", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingConfigUrl, " ");

            ExtendedPropertyDefinition PidLidSharingFlavor = new ExtendedPropertyDefinition(PropertySetSharing, 0x823D, MapiPropertyType.Integer);
            invitationRequest.SetExtendedProperty(PidLidSharingFlavor, 0x00020500);

            ExtendedPropertyDefinition PidNameXSharingFlavor = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Flavor", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingFlavor, "20500");

            ExtendedPropertyDefinition PidLidSharingCapabilities = new ExtendedPropertyDefinition(PropertySetSharing, 0x823C, MapiPropertyType.Integer);
            invitationRequest.SetExtendedProperty(PidLidSharingCapabilities, 0x00040290);

            // [MS-OXSHARE] 2.2.2.2
            ExtendedPropertyDefinition PidNameXSharingCapabilities = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Capabilities", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingCapabilities, "40290");

            // [MS-OXSHARE] 2.2.2.10
            ExtendedPropertyDefinition PidLidSharingLocalType = new ExtendedPropertyDefinition(PropertySetSharing, 0x824F, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingLocalType, "IPF.Appointment");

            // [MS-OXSHARE] 2.2.2.11
            ExtendedPropertyDefinition PidNameXSharingLocalType = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Local-Type", MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidNameXSharingLocalType, "IPF.Appointment");

            // [MS-OXSHARE] 2.2.2.7
            ExtendedPropertyDefinition PidLidSharingInitiatorEntryId = new ExtendedPropertyDefinition(PropertySetSharing, 0x8249, MapiPropertyType.Binary);
            invitationRequest.SetExtendedProperty(PidLidSharingInitiatorEntryId, binInitiatorEntryId);

            // [MS-OXSHARE] 2.2.2.8
            ExtendedPropertyDefinition PidLidSharingInitiatorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8029, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingInitiatorName, "SENDER");

            // [MS-OXSHARE] 2.2.2.9
            ExtendedPropertyDefinition PidLidSharingInitiatorSMTP = new ExtendedPropertyDefinition(PropertySetSharing, 0x8248, MapiPropertyType.String);
            invitationRequest.SetExtendedProperty(PidLidSharingInitiatorSMTP, "sender mail adress");

            // Add recipient info and send message
            invitationRequest.ToRecipients.Add("Receiver mail adress");
            invitationRequest.SendAndSaveCopy();
        }
     
       
      
      
    This is the main part of creating the message and sending it.
    To understand this issue I used the following sites and documentation:

    understanding-sharing-invitation-requests-ews-managed-api-1-2-part-1
    MS-OXSHARE].pdf (especially "4.1 Sending a Sharing Request")

    (please Google for this as links aren't accepted here)

      
      
    The problem is that the message created is visible in outlook but not valid. Outlook says invalid message and allow/deny is greyed out.
      
    Is someone out there who has an idea or even solved the same issue? Thank you!

    Monday, February 4, 2019 1:05 PM