当前位置: 首页 > 工具软件 > EWS-Client > 使用案例 >

php-ews发送邮件,PHP-EWS将电子邮件移动到文件夹

钱季
2023-12-01

我正在使用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 = $response_message->ResponseCode;

$message = $response_message->MessageText;

continue;

}

$items = $response_message->RootFolder->Items->Message;

foreach ($items as $item) {

$subject = $item->Subject;

$sender = $item->From->Mailbox->EmailAddress;

//move mail item from folder "INBOX" to folder "DONE"

}

}

 类似资料: