【问题标题】:Exchange ItemID differs from GlobalAppointmentID for Outlook AddInExchange ItemID 与 Outlook AddIn 的 GlobalAppointmentID 不同
【发布时间】:2013-05-15 22:36:22
【问题描述】:

我遇到的问题是使用 Outlook FormRegion 创建的 Outlook 约会的 GlobalAppointmentID 与使用 EWS 托管 API 时的 ItemID 不同。

我正在创建一个 Outlook 插件,允许用户将客户和项目信息添加到会议中。插件还将约会 ID 和会议数据存储在数据库中,服务将定期检查 ID 以更新约会数据。

好的,这就是我使用插件的方式:

Outlook.AppointmentItem appointement = (Outlook.AppointmentItem)this.OutlookItem;

appointement.Save();

string ExchangeID = appointement.GlobalAppointmentID;

这里的 GlobalAppointmentID 是:040000008200E00074C5B7101A82E0080000000060CADC517255CE01000000000000000010000000847A9CD89052DC49BA28DC8AAFBBB4BA

但 EWS 托管 API 需要以下内容: AAMkADViNTJlZTg5LTIwYWMtNGY3My1hOWZiLTZiOTM3OTk3Nzk1YQBGAAAAAAAEfbmEhAMsRZur9AvsphPMBwCysaa5HwPMRanSoWSnKrckAAAAXAL/AACysaa5HwPMRanSoWSnKrckAAAAXCxwAAA=

从服务中绑定一个 AppointmentItem。有一个选项可以解决这个问题,但只能使用自动生成的代理而不是托管 API link to proxy solution

那么有没有办法从 EWS 托管 API 搜索 GlobalAppointementID 或从 Outlook 插件检索 ItemID?

【问题讨论】:

    标签: outlook exchange-server outlook-addin exchangewebservices outlook-form


    【解决方案1】:

    Outlook 约会 ID 包含外部 (iCal) 约会 ID。你需要解析它:http://msdn.microsoft.com/en-us/library/ee157690(v=exchg.80).aspx

    【讨论】:

    • 我不确定我是否在关注你。您是说 GlobalAppointementID 包装了 Exchange ItemID 吗?我不认为是这种情况,因为 ItemID 比 GlobalAppointementID 长。
    • 我说的是约会 id,例如,当 iCal 格式的传入会议请求转换为 Outlook 约会时设置。原始约会 ID 将包含在 GlobalApppointementID 属性中。如果您在谈论条目 id,那么 Jan 给出的答案应该适合您。
    【解决方案2】:

    ID 可以用不同的方式表示。 Outlook 使用第一种形式,EWS 使用第二种形式。

    要转换,请使用ConvertID 方法。

    以下是原始 SOAP 格式的请求/响应调用示例(通过这些示例,您应该能够使用 API 实现它们):
    Outlook HexEntryID 到 Exchange EWSID

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
       <soapenv:Header>
          <typ:RequestServerVersion Version="Exchange2007_SP1"/>
          <typ:MailboxCulture>en-US</typ:MailboxCulture>
       </soapenv:Header>
       <soapenv:Body>
          <mes:ConvertId DestinationFormat="EwsId">
             <mes:SourceIds>
                <typ:AlternateId Format="HexEntryId" Id="0000000068C940C[snip]63136C3D0000" Mailbox="user@domain.com"/>
             </mes:SourceIds>
          </mes:ConvertId>
       </soapenv:Body>
    </soapenv:Envelope>
    
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
             <m:ResponseMessages>
                <m:ConvertIdResponseMessage ResponseClass="Success">
                   <m:ResponseCode>NoError</m:ResponseCode>
                   <m:AlternateId xsi:type="t:AlternateIdType" Format="EwsId" Id="AQMkADkyZTQxNjUzL[snip]YxNsPQAAAA==" Mailbox="user@domain.com"/>
                </m:ConvertIdResponseMessage>
             </m:ResponseMessages>
          </m:ConvertIdResponse>
       </s:Body>
    </s:Envelope>
    

    将 EWSID 交换为 Outlook HexEntryID:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
       <soapenv:Header>
          <typ:RequestServerVersion Version="Exchange2007_SP1"/>
       </soapenv:Header>
       <soapenv:Body>
          <mes:ConvertId DestinationFormat="HexEntryId">
             <mes:SourceIds>
                <typ:AlternateId Format="EwsId" Id="AQMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmIBNWJi[snip]YxNsPQAAAA==" Mailbox="user@domain.com"/>
             </mes:SourceIds>
          </mes:ConvertId>
       </soapenv:Body>
    </soapenv:Envelope>
    
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
             <m:ResponseMessages>
                <m:ConvertIdResponseMessage ResponseClass="Success">
                   <m:ResponseCode>NoError</m:ResponseCode>
                   <m:AlternateId xsi:type="t:AlternateIdType" Format="HexEntryId" Id="0000000068C940[snip]136C3D0000" Mailbox="user@domain.com"/>
                </m:ConvertIdResponseMessage>
             </m:ResponseMessages>
          </m:ConvertIdResponse>
       </s:Body>
    </s:Envelope>
    

    请注意,在使用定期约会和事件时,使用这两种类型的 ID 有所不同:
    在每次出现 EWS ID 不同的情况下,Outlook 十六进制条目 ID 都是相同的:

    FindItem 对重复事件的响应,但有一个例外 - 请注意不同的 ItemID:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
             <m:ResponseMessages>
                <m:FindItemResponseMessage ResponseClass="Success">
                   <m:ResponseCode>NoError</m:ResponseCode>
                   <m:RootFolder TotalItemsInView="10" IncludesLastItemInRange="true">
                      <t:Items>
                         <t:CalendarItem>
                            <t:ItemId Id="AAMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmJiNWJiNTBlNgFRAAgI0B8WRv2AAEYAAAAAgq3iY5OVdkmtnHS/lxCbwgcAhKYXWHH/akCFAFNVQGZiCgAAAAAAIQAAhKYXWHH/akCFAFNVQGZiCgACKa9YrQAAEA==" ChangeKey="DwAAABYAAACEphdYcf9qQIUAU1VAZmIKAAIpr2i3"/>
                            <t:ItemClass>IPM.Appointment.Occurrence</t:ItemClass>
                            <t:Subject>Recurring appointment with one exception</t:Subject>
                            <t:Sensitivity>Normal</t:Sensitivity>
                            <t:DateTimeCreated>2013-05-22T06:51:26Z</t:DateTimeCreated>
                            <t:LastModifiedTime>2013-05-22T06:52:20Z</t:LastModifiedTime>
                            <t:Start>2013-05-15T10:30:00Z</t:Start>
                            <t:End>2013-05-15T11:00:00Z</t:End>
                            <t:IsRecurring>true</t:IsRecurring>
                            <t:CalendarItemType>Occurrence</t:CalendarItemType>
                         </t:CalendarItem>
                         <t:CalendarItem>
                            <t:ItemId Id="AAMkADkyZTQxNjUzLTcwZTQtNGRlNS04M2VmLWMxYmJiNWJiNTBlNgFRAAgI0B/fcWdAAEYAAAAAgq3iY5OVdkmtnHS/lxCbwgcAhKYXWHH/akCFAFNVQGZiCgAAAAAAIQAAhKYXWHH/akCFAFNVQGZiCgACKa9YrQAAEA==" ChangeKey="DwAAABYAAACEphdYcf9qQIUAU1VAZmIKAAIpr2i3"/>
                            <t:ItemClass>IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}</t:ItemClass>
                            <t:Subject>The exception</t:Subject>
                            <t:Sensitivity>Normal</t:Sensitivity>
                            <t:DateTimeCreated>2013-05-22T06:51:58Z</t:DateTimeCreated>
                            <t:LastModifiedTime>2013-05-22T06:52:20Z</t:LastModifiedTime>
                            <t:Start>2013-05-16T12:00:00Z</t:Start>
                            <t:End>2013-05-16T12:30:00Z</t:End>
                            <t:IsRecurring>true</t:IsRecurring>
                            <t:CalendarItemType>Exception</t:CalendarItemType>
                         </t:CalendarItem>
                         [snip]
                         Other occurrences removed
                         [snip]
                      </t:Items>
                   </m:RootFolder>
                </m:FindItemResponseMessage>
             </m:ResponseMessages>
          </m:FindItemResponse>
       </s:Body>
    </s:Envelope>
    

    将这两个 ItemID 的 EWSID 转换为 HexEntryID 会导致

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
             <m:ResponseMessages>
                <m:ConvertIdResponseMessage ResponseClass="Success">
                   <m:ResponseCode>NoError</m:ResponseCode>
                   <m:AlternateId xsi:type="t:AlternateIdType" Format="HexEntryId" Id="0000000082ADE26393957649AD9C74BF97109BC2070084A6175871FF6A40850053554066620A000000000021000084A6175871FF6A40850053554066620A000229AF58AD0000" Mailbox="user@domain.com"/>
                </m:ConvertIdResponseMessage>
             </m:ResponseMessages>
          </m:ConvertIdResponse>
       </s:Body>
    </s:Envelope>
    
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
       </s:Header>
       <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
             <m:ResponseMessages>
                <m:ConvertIdResponseMessage ResponseClass="Success">
                   <m:ResponseCode>NoError</m:ResponseCode>
                   <m:AlternateId xsi:type="t:AlternateIdType" Format="HexEntryId" Id="0000000082ADE26393957649AD9C74BF97109BC2070084A6175871FF6A40850053554066620A000000000021000084A6175871FF6A40850053554066620A000229AF58AD0000" Mailbox="user@domain.com"/>
                </m:ConvertIdResponseMessage>
             </m:ResponseMessages>
          </m:ConvertIdResponse>
       </s:Body>
    </s:Envelope>
    

    【讨论】:

    • 效果不错!或者至少这里的一个版本是你如何使用转换函数和 EWS Mangaed API link
    • 只是澄清一下,您使用 Outlook 中的 Appointment 对象的 EntryID 转换为十六进制,使用类似:private static string GetObjectIdStringFromUid(string id) { var buffer = new byte[id.Length / 2]; for (int i = 0; i &lt; id.Length / 2; i++) { var hexValue = byte.Parse(id.Substring(i * 2, 2), NumberStyles.AllowHexSpecifier); buffer[i] = hexValue; } return Convert.ToBase64String(buffer); }
    猜你喜欢
    • 2022-01-15
    • 2017-11-18
    • 1970-01-01
    • 2011-01-14
    • 2011-05-09
    • 2020-06-01
    • 1970-01-01
    • 2012-08-03
    • 1970-01-01
    相关资源
    最近更新 更多