通过EWS更新日历事件后,Outlook中显示的时区不正确 [英] Incorrect time zone displayed in Outlook after updating a calendar event through EWS

查看:122
本文介绍了通过EWS更新日历事件后,Outlook中显示的时区不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having an issue with time zones when updating an appointment.

第1步,创建一个活动,效果很好

首先,我创建一个活动,该活动的运行时间为本地时间10:00至11:00(阿姆斯特丹DST,所以UTC + 2).
我的Exchange服务器2010(SP2)知道欧洲标准时间"时区.
没问题,这是Outlook 2007中的事件:

First I create a single event, running from 10:00 to 11:00 local time (Amsterdam DST, so UTC+2).
My Exchange server 2010 (SP2) knows the "W. Europe Standard Time" timezone.
No issue there, here's the event in Outlook 2007:

这是创建事件的XML:

This is the XML that creates the event:

<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,并为开始/完成"指定了明确的时区,以便Exchange Server知道如何将其转换为UTC,而不必依赖服务器时区(请参阅

Note that I specify the MeetingTimeZone, and give Start/Finish an explicit time zone, so that Exchange Server knows how to convert it to UTC without having to rely on the server time zone (see Best Practices for Using Exchange Web Services for Calendaring Tasks).
I tried leaving out all time zone info when creating the event, but this immediately gives me the 'Reykjavik effect' of step 2. Anyway, step 1 works fine.

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

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

Now I modify the event caption only; I need to specify all items again (my code has no idea what changed):

<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>

但现在我明白了:
该事件会在压延机概述中正确显示

but now I get this:
The event shows properly in the calender overview

但是当我打开它时,我突然得到不正确的雷克雅未克"时间:

but when I open it I suddenly get incorrect 'Reykjavik' times:

请注意,UpdateItem调用的标题仍然具有

Note that the header of the UpdateItem call still has the

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

但没有

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

就像在CreateItem调用中一样,在呼叫中

.

in the call, as there was in the CreateItem call.

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

If I try to put it in like this I get an error "The specified object was not found in the store":

<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放置在文件中的其他位置,但一直收到语法错误.

I have tried placing MeetingTimeZone at other locations in the file but keep getting syntax errors.

将TimeZoneContext留在UpdateItem的标题中并不能解决问题(根据我在

Leaving the TimeZoneContext out of the header of the UpdateItem does not solve the issue (and from what I understand in TimeZoneContext documentation I should use it).

我需要使用MeetingTimeZone来实现与Exchange Server 2007 SP1的向后兼容性(不建议使用更高版本的MeetingTimeZone,我们应该使用StartImeZone/EndTimeZone).

I need to use MeetingTimeZone for backward compatibility to Exchange Server 2007 SP1 (for later versions MeetingTimeZone is deprecated and we should use StartImeZone/EndTimeZone).

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

背景信息:

  • Exchange服务器版本返回:

<ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="195" MinorBuildNumber="1" Version="Exchange2010_SP2"/>

  • 本地Outlook设置为阿姆斯特丹时区(由于DST,当前为UTC + 2).

  • Local Outlook setting is Amsterdam timezone (currently UTC+2 because of DST).

这是一个EWS托管API用户,遇到类似的问题但没有解决方案.

推荐答案

我明白了!多亏了此

I got it! Thanks to this EWS Calendar Recurrence Item Update - TimeZone problem post.

实际上您不能只插入

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

在SOAP请求中的某处

行,但是您还必须将MeetingTimeZone指定为要更改的CalendarItem元素.
因此,必须将此附加项插入通话:

line somewhere in the SOAP request, but you also have to specify MeetingTimeZone as a CalendarItem element that you want to change.
So this additional item has to be inserted into the call:

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

并确保将其放置在正确的位置,因为必须按照

And make sure to put it at the right place, because the items have to be specified in the order as defined in the CalendarItem type

这篇关于通过EWS更新日历事件后,Outlook中显示的时区不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆