I was able to successfully get unread emails from my Exchange 2010 inbox using the php-ews API. However, after I received the emails, I want the IsRead property for the email to be true, so that these messages do not appear the next time the emails are received.
Has anyone done this before?
EDIT:
This is how I try to set the IsRead flag:
$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(); } }
When I run the file, I get the following error:
An internal server error occurred. The operation failed.
After debugging for some time, I came to the conclusion that an error occurs in the curl_exec function in the NTLMSoapClient.php file.
I donβt know where to go next. Please, help.
Lin source share