EWS:日历共享邀请和扩展属性

时间:2012-03-31 18:30:27

标签: c# web-services calendar exchange-server exchangewebservices

好的,到目前为止,关于这个主题我得到的最好的信息是在这个帖子上: EWS-API-Create-Calendar-and-Share-with-reviewer-permissions。我试着在那个帖子上问这个问题,但实际上我把它作为答案发布了,所以它被管理员删除了(我的坏!)

免责声明:我是一名通过贸易和月光开发的系统管理员...所以请原谅任何滥用术语或混乱的问题。

另外,我在C#这里工作。

我已经阅读了microsoft的消息协议规范,并了解需要在消息项上创建某些扩展属性才能正确创建共享邀请对象,我从上面提到的帖子中了解到,我可以创建一个具有扩展属性的消息对象(确切地说SetExtendedProperty(extprop,value))。我知道我必须手动创建我使用new ExtendedProperty()设置的扩展属性,并在每个属性上填充正确的父GUID,HexID和数据类型。从我可以收集的内容来看,这或多或少是一种“解决方法”,因为API中没有内置的共享对象管理功能......

但是我遇到了麻烦,需要澄清......

我想手动创建共享邀请(通过客户端,“用户”方式),然后附加到发送邀请的用户的“已发送邮件”框中的邮件。我想枚举相对于我需要用来构建类似对象的所有可能属性,以便我可以将它用作模板并将我的对象属性与原始邀请进行比较。我可以得到消息很好并找到许多属性,但不是任何“特殊”属性。我唯一可以找到区分消息项的事实是它是IPM.Sharing项类,并且它的附件为sharing_metadata.xml

但我现在假设我们可以通过使用扩展属性通过API创建共享邀请,这是否正确,这并不一定意味着我们可以通过API读取这些属性?

我尝试枚举扩展属性的所有内容似乎都不起作用,并且总是返回任何内容而不是扩展属性数组。也许我做得不对,但我想在花费无数个小时试图去实现一些不可能的事情之前先问这个问题。

因此,如果我无法正确枚举扩展属性,是否有可能使用ExFoldersMFCMAPI之类的东西来获取这些属性?

任何想法/建议/批评?

谢谢!

更新:

继承我正在玩的功能,尝试为用户日历文件夹创建共享邀请...我已经评论了我被困住的地方以及我没有完全包围我的想法:

    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 个答案:

答案 0 :(得分:2)

好吧我明白了......但这并不容易。如果您对我如何通过Exchange 2010的EWS API 1.2发送共享邀请感兴趣,您可以阅读here