如果通过 EWS API 创建,如何为 Outlook Appointment.When 设置时区
How to Set Timezone for Outlook Appointment.When if created via EWS API
我们正在使用 Exchange Web 服务 API 创建约会。我们在创建时将时区设置为本地时区。当收件人查看邀请时,是他当地时区的正确时间,唯一的是Exchange在约会正文的开头添加了"When"和"Where",如下所示:
无论最终用户的时区是什么,When 的时区始终采用 UTC 时区。这会给我们客户的最终用户带来一些困惑。从EWS API Document for Appointment.When属性开始,只有Get方法,没有Set方法。在一项测试中,我们尝试将首选文化设置为 de-de-de-culture as document is suggested 并且 "When" 仍以 UTC 时间显示。
不知何故,我在互联网上找不到任何相关信息。任何人都可以在这里阐明如何在特定时区显示 "When" 吗?
您所看到的内容在消息 body 中被称为下层文本,问题通常发生在更新约会期间,您似乎在更新约会,就像您张贴的图片的最后一行一样。问题是因为时区没有作为更新请求的一部分发送,服务器会将下层文本设置为 utc。一种解决方法是您可以使用
手动添加 TimeZoneContext header
OnSerializeCustomSoapHeaders 事件例如
service.OnSerializeCustomSoapHeaders += service_OnSerializeCustomSoapHeaders;
appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
service.OnSerializeCustomSoapHeaders -= service_OnSerializeCustomSoapHeaders;
static void service_OnSerializeCustomSoapHeaders(XmlWriter writer)
{
writer.WriteRaw(Environment.NewLine + " <t:TimeZoneContext><t:TimeZoneDefinition Id=\"" + TimeZone.CurrentTimeZone.StandardName + "\"/></t:TimeZoneContext>" + Environment.NewLine);
}
我们正在使用 Exchange Web 服务 API 创建约会。我们在创建时将时区设置为本地时区。当收件人查看邀请时,是他当地时区的正确时间,唯一的是Exchange在约会正文的开头添加了"When"和"Where",如下所示:
无论最终用户的时区是什么,When 的时区始终采用 UTC 时区。这会给我们客户的最终用户带来一些困惑。从EWS API Document for Appointment.When属性开始,只有Get方法,没有Set方法。在一项测试中,我们尝试将首选文化设置为 de-de-de-culture as document is suggested 并且 "When" 仍以 UTC 时间显示。
不知何故,我在互联网上找不到任何相关信息。任何人都可以在这里阐明如何在特定时区显示 "When" 吗?
您所看到的内容在消息 body 中被称为下层文本,问题通常发生在更新约会期间,您似乎在更新约会,就像您张贴的图片的最后一行一样。问题是因为时区没有作为更新请求的一部分发送,服务器会将下层文本设置为 utc。一种解决方法是您可以使用
手动添加 TimeZoneContext headerOnSerializeCustomSoapHeaders 事件例如
service.OnSerializeCustomSoapHeaders += service_OnSerializeCustomSoapHeaders;
appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
service.OnSerializeCustomSoapHeaders -= service_OnSerializeCustomSoapHeaders;
static void service_OnSerializeCustomSoapHeaders(XmlWriter writer)
{
writer.WriteRaw(Environment.NewLine + " <t:TimeZoneContext><t:TimeZoneDefinition Id=\"" + TimeZone.CurrentTimeZone.StandardName + "\"/></t:TimeZoneContext>" + Environment.NewLine);
}