我已经能够使用 php-ews API 从 Exchange 2010 收件箱中成功检索未读电子邮件。但是,在我获取电子邮件后,我想将电子邮件的 IsRead 属性设置为 true,以便下次获取电子邮件时不会出现这些消息。
以前有人做过吗?
编辑 :
这就是我尝试设置 IsRead 标志的方式:
$message_id = ''; //id of message
$change_key = ''; //change key
$response = $ews->GetItem($request);
//print_r($response);exit;
if( $response->ResponseMessages->GetItemResponseMessage->ResponseCode == 'NoError' &&
$response->ResponseMessages->GetItemResponseMessage->ResponseClass == 'Success' ) {
$a = array();
$message = $response->ResponseMessages->GetItemResponseMessage->Items->Message;
$a['message_body'] = $message->Body->_;
$a['sender'] = $message->From->Mailbox->EmailAddress;
$a['subject'] = $message->ConversationTopic;
$data[] = $a;
//process the message data.
$messageType = new EWSType_MessageType();
$messageType->IsRead = true;
$path = new EWSType_PathToUnindexedFieldType();
$path->FieldURI = 'message:IsRead';
$setField = new EWSType_SetItemFieldType();
$setField->Message = $messageType;
$setField->FieldURI = $path;
$u = new EWSType_ItemChangeType();
$u->Updates = new EWSType_NonEmptyArrayOfItemChangeDescriptionsType();
$u->Updates->SetItemField = $setField;
$u->ItemId = new EWSType_ItemIdType();
$u->ItemId->Id = $message_id;
$u->ItemId->ChangeKey = $change_key;
$updatedItems = new EWSType_NonEmptyArrayOfItemChangesType();
$updatedItems->ItemChange = $u;
$updateMessenger = new EWSType_UpdateItemType();
$updateMessenger->ItemChanges = $updatedItems;
$updateMessenger->MessageDisposition = 'SaveOnly';
$updateMessenger->ConflictResolution = 'AutoResolve';
try {
$update_response = $ews->UpdateItem($updateMessenger);
}catch (Exception $e){
echo $e->getMessage();
}
}
当我运行该文件时,出现以下错误:
An internal server error occurred. The operation failed.
经过一段时间的调试,我得出的结论是错误发生在 NTLMSoapClient.php 文件中的 curl_exec 函数处。
我不知道从这里开始。请帮忙。