【问题标题】:Incorrect time zone displayed in Outlook after updating a calendar event through EWS通过 EWS 更新日历事件后,Outlook 中显示的时区不正确
【发布时间】:2014-08-20 08:21:16
【问题描述】:

我在更新约会时遇到了时区问题。

第 1 步,创建单个事件,工作正常

首先,我创建一个事件,从当地时间 10:00 到 11:00(阿姆斯特丹 DST,因此 UTC+2)运行。
我的 Exchange 服务器 2010 (SP2) 知道“西欧标准时间”时区。
没问题,这是 Outlook 2007 中的事件:

这是创建事件的 XML:

<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>
  <typ:TimeZoneContext>
     <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
  </typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
   <mes:CreateItem SendMeetingInvitations="SendToNone">
      <mes:SavedItemFolderId>
         <typ:DistinguishedFolderId Id="calendar">
            <typ:Mailbox>
               <typ:EmailAddress>developer@timetellbv.nl</typ:EmailAddress>
            </typ:Mailbox>
         </typ:DistinguishedFolderId>
      </mes:SavedItemFolderId>
      <mes:Items>
         <typ:CalendarItem>
           <typ:Subject>New event 10:00-11:00</typ:Subject>
           <typ:Body BodyType="Text"></typ:Body>
           <typ:Categories>
             <typ:String>TimeTell</typ:String>
           </typ:Categories>
           <typ:ReminderIsSet>false</typ:ReminderIsSet>
           <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
           <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
           <typ:IsAllDayEvent>false</typ:IsAllDayEvent>
           <typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
           <typ:Location></typ:Location>
           <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
         </typ:CalendarItem>
      </mes:Items>
   </mes:CreateItem>
</soapenv:Body>
</soapenv:Envelope>

请注意,我指定了 MeetingTimeZone,并为 Start/Finish 提供了一个明确的时区,以便 Exchange Server 知道如何将其转换为 UTC 而不必依赖服务器时区(请参阅Best Practices for Using Exchange Web Services for Calendaring Tasks)。
我尝试在创建事件时省略所有时区信息,但这立即给了我第 2 步的“雷克雅未克效应”。无论如何,第 1 步工作正常。

第 2 步,更新单个事件,失败:更改 Outlook 中显示的时区

现在我只修改事件标题;我需要再次指定所有项目(我的代码不知道发生了什么变化):

<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>
  <typ:TimeZoneContext>
     <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
  </typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone">
   <mes:ItemChanges>
      <typ:ItemChange>
         <typ:ItemId Id="AQMkAZ[snip]hgAAAA==" ChangeKey="DwAAA[snip]yy5AX"/>
         <typ:Updates>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Subject"/>
               <typ:CalendarItem>
                 <typ:Subject>New event 10:00-11:00 (modified)</typ:Subject>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Sensitivity"/>
               <typ:CalendarItem>
                 <typ:Sensitivity>Normal</typ:Sensitivity>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Categories"/>
               <typ:CalendarItem>
                  <typ:Categories>
                     <typ:String>TimeTell</typ:String>
                  </typ:Categories>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:Body"/>
               <typ:CalendarItem>
                 <typ:Body BodyType="Text"></typ:Body>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Location"/>
               <typ:CalendarItem>
                 <typ:Location></typ:Location>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="item:ReminderIsSet"/>
               <typ:CalendarItem>
                 <typ:ReminderIsSet>false</typ:ReminderIsSet>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:IsAllDayEvent"/>
               <typ:CalendarItem>
                 <typ:IsAllDayEvent>false</typ:IsAllDayEvent>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:Start"/>
               <typ:CalendarItem>
                 <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:End"/>
               <typ:CalendarItem>
                 <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:FieldURI FieldURI="calendar:LegacyFreeBusyStatus"/>
               <typ:CalendarItem>
                 <typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellID" PropertyType="Integer"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellID" PropertyType="Integer"/>
                     <typ:Value>10722</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncTime" PropertyType="SystemTime"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncTime" PropertyType="SystemTime"/>
                     <typ:Value>2014-08-19T16:22:22.094+02:00</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncVer" PropertyType="Integer"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncVer" PropertyType="Integer"/>
                     <typ:Value>80000</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
            <typ:SetItemField>
               <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncID" PropertyType="String"/>
               <typ:CalendarItem>
                  <typ:ExtendedProperty>
                     <typ:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="TimeTellSyncID" PropertyType="String"/>
                     <typ:Value>0000000082ADE26393957649AD9C74BF97109BC2070084A6175871FF6A40850053554066620A000000000021000084A6175871FF6A40850053554066620A000232CB43830000</typ:Value>
                  </typ:ExtendedProperty>
               </typ:CalendarItem>
            </typ:SetItemField>
         </typ:Updates>
      </typ:ItemChange>
   </mes:ItemChanges>
 </mes:UpdateItem>
</soapenv:Body>
</soapenv:Envelope>

但现在我明白了:
该事件在日历概览中正确显示

但是当我打开它时,我突然得到了错误的“雷克雅未克”时间:

请注意,UpdateItem 调用的标头仍有

<typ:TimeZoneContext>
   <typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
</typ:TimeZoneContext>

但是没有

<typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>

在调用中,就像在 CreateItem 调用中一样。

如果我尝试这样放入,我会收到错误“在商店中找不到指定的对象”:

<typ:SetItemField>
   <typ:FieldURI FieldURI="calendar:Start"/>
   <typ:CalendarItem>
     <typ:Start>2014-08-19T10:00:00.000+02:00</typ:Start>
     <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
   </typ:CalendarItem>
</typ:SetItemField>
<typ:SetItemField>
   <typ:FieldURI FieldURI="calendar:End"/>
   <typ:CalendarItem>
     <typ:End>2014-08-19T11:00:00.000+02:00</typ:End>
     <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
   </typ:CalendarItem>
</typ:SetItemField>

我尝试将 MeetingTimeZone 放在文件中的其他位置,但不断出现语法错误。

将 TimeZoneContext 排除在 UpdateItem 的标头之外并不能解决问题(根据我在 TimeZoneContext documentation 中的理解,我应该使用它)。

我需要使用 MeetingTimeZone 来向后兼容 Exchange Server 2007 SP1(对于更高版本的 MeetingTimeZone 已弃用,我们应该使用 StartImeZone/EndTimeZone)。

问题:如何更改 UpdateItem 调用以确保我的 Outlook 事件保持正确的时间(区域)?

背景资料:

  • Exchange 服务器版本返回:

&lt;ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1" Version="Exchange2010_SP2"/&gt;

【问题讨论】:

    标签: outlook timezone exchange-server exchangewebservices outlook-2007


    【解决方案1】:

    我明白了!感谢这个EWS Calendar Recurrence Item Update - TimeZone problem 帖子。

    确实你不能只插入一个

    <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
    

    在 SOAP 请求中的某处行,但您还必须将 MeetingTimeZone 指定为要更改的 CalendarItem 元素
    所以这个额外的项目必须插入到调用中:

    <typ:SetItemField>
       <typ:FieldURI FieldURI="calendar:MeetingTimeZone"/>
       <typ:CalendarItem>
          <typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time" />
       </typ:CalendarItem>               
    </typ:SetItemField>
    

    并确保将其放在正确的位置,因为必须按照CalendarItem type中定义的顺序指定项目

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 2020-06-04
      相关资源
      最近更新 更多