我正在使用php-ews获取附件并将它们保存到特定目录,现在我需要将邮件移动到另一个文件夹中.我卡在这里:
$client = new Client($host, $username, $password, $version);
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
// Return all message properties.
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
// Search in the user's inbox.
$folder_id = new DistinguishedFolderIdType();
$folder_id->Id = DistinguishedFolderIdNameType::INBOX;
$request->ParentFolderIds->DistinguishedFolderId[] = $folder_id;
$response = $client->FindItem($request);
// Iterate over the results, printing any error messages or message subjects.
$response_messages = $response->ResponseMessages->FindItemResponseMessage;
foreach ($response_messages as $response_message) {
// Make sure the request succeeded.
if ($response_message->ResponseClass != ResponseClassType::SUCCESS) {
$code = …Run Code Online (Sandbox Code Playgroud) 已经在stackoverflow(Appointment.Save和Appointment.Update始终将IsMeeting设置为true)上讨论过,EWS在如何在公共文件夹中创建新的日历项目/会议时无法自动发送会议邀请时受到限制.
由于我真的需要将会议发送给各个与会者的日历,我想知道是否有人发现了这种奇怪行为的解决方法(我甚至找不到以编程方式发送会议邀请的方法).
似乎唯一有效的方法是将日历项目转发到与会者的地址,但这实际上不是一个选项,因为它只会使会议作为电子邮件中的附件提供.
以下代码适用于单个附件,但与多个文件失败.
<?php
$msgRequest->MessageDisposition = 'SaveOnly';
$msgResponse = $ews->CreateItem($msgRequest);
$msgResponseItems = $msgResponse->ResponseMessages->CreateItemResponseMessage->Items;
// Create attachment(s)
$attachments = array();
$i = 0;
foreach ($message_details['attachment'] as $attachment) {
$attachments[$i] = new EWSType_FileAttachmentType();
$attachments[$i]->Content = file_get_contents($attachment['path'] . '/' . $attachment['file']);
$attachments[$i]->Name = $attachment['file'];
$i++;
}
//
// Attach files to message
$attRequest = new EWSType_CreateAttachmentType();
$attRequest->ParentItemId = $msgResponseItems->Message->ItemId;
$attRequest->Attachments = new EWSType_NonEmptyArrayOfAttachmentsType();
$attRequest->Attachments->FileAttachment = $attachments;
$attResponse = $ews->CreateAttachment($attRequest);
$attResponseId = $attResponse->ResponseMessages->CreateAttachmentResponseMessage->Attachments->FileAttachment->AttachmentId;
// Save message id from create attachment response
$msgItemId …Run Code Online (Sandbox Code Playgroud)