Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP and Exchange Web Services : fetching the message body using php-ews
    primarykey
    data
    text
    <p>I am having no luck fetching the message body of an email from an Exchange 2010 server using php-ews. This is my code :</p> <pre><code>$ews = new ExchangeWebServices("hostname", "username","password",ExchangeWebServices::VERSION_2010); $request = new EWSType_FindItemType(); $itemProperties = new EWSType_ItemResponseShapeType(); $itemProperties-&gt;BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES; $itemProperties-&gt;BodyType = EWSType_BodyTypeResponseType::BEST; $request-&gt;ItemShape = $itemProperties; //If I do not include the below three sentences I get a PHP Fatal error saying "Basepoint" not found $request-&gt;IndexedPageItemView = new EWSType_IndexedPageViewType(); $request-&gt;IndexedPageItemView-&gt;BasePoint = 'Beginning'; $request-&gt;IndexedPageItemView-&gt;Offset = 0; $request-&gt;ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType(); $request-&gt;ParentFolderIds-&gt;DistinguishedFolderId = new EWSType_DistinguishedFolderIdType(); $request-&gt;ParentFolderIds-&gt;DistinguishedFolderId-&gt;Id = EWSType_DistinguishedFolderIdNameType::INBOX; $request-&gt;Traversal = EWSType_ItemQueryTraversalType::SHALLOW; $result = new EWSType_FindItemResponseMessageType(); $result = $ews-&gt;FindItem($request); if ($result-&gt;ResponseMessages-&gt;FindItemResponseMessage-&gt;ResponseCode == 'NoError' &amp;&amp; $result-&gt;ResponseMessages-&gt;FindItemResponseMessage-&gt;ResponseClass == 'Success'){ $message = $result-&gt;ResponseMessages-&gt;FindItemResponseMessage-&gt;Items-&gt;Message; //This if loop is entered but the $message variable contains nothing print_r($message);exit; //var_dump($message) displays NULL } </code></pre> <p>The "if" loop is entered however the $message variable contains nothing. Typically it should be an object from which I can retrieve the body of the email.</p> <p>What am I doing wrong ?</p> <p>I tried this inside the if() statement and I got the $message object :</p> <pre><code>$message = $result-&gt;ResponseMessages-&gt;FindItemResponseMessage-&gt;RootFolder-&gt;Items-&gt;Message; print_r($message);exit; </code></pre> <p>The "RootFolder" attribute was missing. However the resulting $message variable does not contain any "body" attribute that contains the body of the email. This is how the print_r($message) looks like : </p> <pre><code>stdClass Object </code></pre> <p>( [ItemId] => stdClass Object ( [Id] => AAMkADZjOTZhNjNkLTBmZTAtNDdkZi04NGI5LTdiZWY0ZWYzOGNhMwBGAAAAAABI9LX/rIDdRr5XMdDM8RGZBwAL3uOTQAYYQ4U8CTQP/+wKAAAAWsnbAAAL3uOTQAYYQ4U8CTQP/+wKAAAAWvd0AAA= [ChangeKey] => CQAAABYAAAAL3uOTQAYYQ4U8CTQP/+wKAAAAWyCi )</p> <pre><code>[ParentFolderId] =&gt; stdClass Object ( [Id] =&gt; AQMkADZjOTZhNjNkLTBmZTAtNDdkZi04NGI5LTdiZWY0ZWYzOGNhMwAuAAADSPS1/6yA3Ua+VzHQzPERmQEAC97jk0AGGEOFPAk0D//sCgAAAVrJ2wAAAA== [ChangeKey] =&gt; AQAAAA== ) [ItemClass] =&gt; IPM.Note [Subject] =&gt; Test [Sensitivity] =&gt; Normal [DateTimeReceived] =&gt; 2012-09-05T13:03:08Z [Size] =&gt; 4754 [Importance] =&gt; Normal [IsSubmitted] =&gt; [IsDraft] =&gt; [IsFromMe] =&gt; [IsResend] =&gt; [IsUnmodified] =&gt; 1 [DateTimeSent] =&gt; 2012-09-05T13:03:00Z [DateTimeCreated] =&gt; 2012-09-05T13:03:08Z [DisplayCc] =&gt; [DisplayTo] =&gt; sara cooper [HasAttachments] =&gt; [Culture] =&gt; en-IN [EffectiveRights] =&gt; stdClass Object ( [CreateAssociated] =&gt; [CreateContents] =&gt; [CreateHierarchy] =&gt; [Delete] =&gt; 1 [Modify] =&gt; 1 [Read] =&gt; 1 ) [LastModifiedName] =&gt; Lin T [LastModifiedTime] =&gt; 2012-09-05T13:03:08Z [IsAssociated] =&gt; [WebClientReadFormQueryString] =&gt; ?ae=Item&amp;a=Open&amp;t=IPM.Note&amp;id=RgAAAABI9LX%2frIDdRr5XMdDM8RGZBwAL3uOTQAYYQ4U8CTQP%2f%2bwKAAAAWsnbAAAL3uOTQAYYQ4U8CTQP%2f%2bwKAAAAWvd0AAAJ&amp;exvsurl=1 [ConversationId] =&gt; stdClass Object ( [Id] =&gt; AAQkADZjOTZhNjNkLTBmZTAtNDdkZi04NGI5LTdiZWY0ZWYzOGNhMwAQAJ56TrE0QUIAk59ALIqWrrY= ) [Sender] =&gt; stdClass Object ( [Mailbox] =&gt; stdClass Object ( [Name] =&gt; Lin T [MailboxType] =&gt; OneOff ) ) [IsReadReceiptRequested] =&gt; [ConversationIndex] =&gt; Í‹fÃIžzN±4AB“Ÿ@,Š–®¶ [ConversationTopic] =&gt; Test [From] =&gt; stdClass Object ( [Mailbox] =&gt; stdClass Object ( [Name] =&gt; Lin T [MailboxType] =&gt; OneOff ) ) [InternetMessageId] =&gt; &lt;027d01cd8b66$c8c967e0$5a5c37a0$@marlabs.com&gt; [IsRead] =&gt; [ReceivedBy] =&gt; stdClass Object ( [Mailbox] =&gt; stdClass Object ( [Name] =&gt; sara cooper [MailboxType] =&gt; OneOff ) ) [ReceivedRepresenting] =&gt; stdClass Object ( [Mailbox] =&gt; stdClass Object ( [Name] =&gt; sara cooper [MailboxType] =&gt; OneOff ) ) </code></pre> <p>)</p> <p>I also need the EMAIL ADDRESS of the sender and the receiver. Here only the first name and last names are displayed. Please help this is getting really urgent.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload