【问题标题】:Php-ews: creating contact birthday's eventphp-ews:创建联系人生日事件
【发布时间】:2014-08-14 15:16:57
【问题描述】:

我正在尝试使用 php-ews 和以下代码在 Exchange 中添加联系人:

$request = new EWSType_CreateItemType();

$request->SendMeetingInvitations = 'SendToNone';

$contact = new EWSType_ContactItemType();
$contact->GivenName = $updates['name'];
$contact->Surname = $updates['surname'];

if($updates['email'] != ""){
    $email = new EWSType_EmailAddressDictionaryEntryType();
    $email->Key = new EWSType_EmailAddressKeyType();
    $email->Key->_ = EWSType_EmailAddressKeyType::EMAIL_ADDRESS_1;
    $email->_ = $updates['email'];

    // set the email
    $contact->EmailAddresses = new EWSType_EmailAddressDictionaryType();
    $contact->EmailAddresses->Entry[] = $email;
}

$contact->CompanyName = $updates['companyname'];

$contact->JobTitle = $updates['jobtitle'];

$contact->Birthday = $updates['birthday'];

$request->Items->Contact[] = $contact;

$response = $this->ews->CreateItem($request);

其中 $updates 是我作为参数的字符串数组。 (我跳过了包含,告诉我你是否需要它们。)

现在,联系人已创建,一切正常,但生日活动并未在我的日历中自动创建。

所以,我想知道是否有一种简单的方法可以完成这项工作,除了手动创建它的明显(非优雅)方法。

提前谢谢你, 里卡多

【问题讨论】:

  • 您能提供一个示例“生日”字符串吗?可能是格式问题。
  • 我很确定这不是格式问题,因为“生日”字段已正确同步,它是未自动创建的相应事件(就像您在 Outlook 中手动设置生日一样)。忘了在问题中提到这一点。我的错。

标签: php outlook exchange-server php-ews


【解决方案1】:

可以按照 cmets 中预期的正确格式使用 DateTime 解决此问题。

$contact->Birthday = (new DateTime($updates['birthday']))->format(DATE_W3C);

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/time-zones-and-ews-in-exchange

在 dateTime 元素的值中指定的时区可以采用三种形式。您可以阅读 XML Schema Part 2: Datatypes Second Edition 中的所有详细信息,但要解释一下:

  • 通用协调时间 (UTC):由“Z”指定。例如,2014-06-06T19:00:00.000Z
  • 特定时区:由“+”或“-”指定,后跟小时和分钟。例如,2014-06-06T19:00:00.000-08:00
  • 无时区:由没有任何时区指定。例如,2014-06-06T19:00:00.000

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    • 1970-01-01
    • 2012-06-24
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多