0

我会尝试使用php-ews转发邮件,但无法正常工作。

我已阅读 XML EWS 的文档

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-respond-to-email-messages-by-using-ews-in-exchange

但我猜我错过了一些东西。

 $request = new CreateItemType();
 $request->MessageDisposition = MessageDispositionType::SEND_AND_SAVE_COPY;
 $request->Items = new NonEmptyArrayOfAllItemsType();
 $request->Items->ForwardedItem = new ForwardItemType();
 $request->Items->ForwardedItem->ToRecipients = new MessageType();
 $request->Items->ForwardedItem->ToRecipients->Mailbox = new EmailAddressType();
 $request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxName = 'Foo Bar';
 $request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxAddress = 'Foo@Bar.com';
 $request->Items->ForwardedItem->ReferenceItemId = new ItemIdType();
 $request->Items->ForwardedItem->ReferenceItemId->Id = 'AAMk.....AAA=';
 $request->Items->ForwardedItem->ReferenceItemId->ChangeKey = 'CQAA.....GOP';
 $request->Items->ForwardedItem->NewBodyContent = new BodyContentType();
 $request->Items->ForwardedItem->NewBodyContent->Value = 'Test';
 $request->Items->ForwardedItem->NewBodyContent->BodyType = BodyTypeType::HTML;

我会得到的错误信息是:

致命错误:未捕获的 SoapFault 异常:[a:ErrorInvalidRequest] Id 必须非空。

4

1 回答 1

0

这看起来不对

 $request->Items->ForwardedItem->ToRecipients = new MessageType();
 $request->Items->ForwardedItem->ToRecipients->Mailbox = new EmailAddressType();
 $request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxName = 'Foo Bar';
 $request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxAddress = 'Foo@Bar.com';

ToRecipients 应该是收件人类型的数组,所以我认为应该是

$request->Items->ForwardedItem->ToRecipients = new ArrayOfRecipientsType();
$recipient = new EmailAddressType();
$recipient->Name = 'Homer Simpson';
$recipient->EmailAddress = 'hsimpson@example.com';
$request->Items->ForwardedItem->ToRecipients->Mailbox[] = $recipient;
于 2019-11-05T22:27:21.687 回答