Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined property: stdClass::$ToRecipients #33

Open
alejosv opened this issue Aug 17, 2019 · 0 comments
Open

Undefined property: stdClass::$ToRecipients #33

alejosv opened this issue Aug 17, 2019 · 0 comments

Comments

@alejosv
Copy link

alejosv commented Aug 17, 2019

Thanks for this repo, it's great !!

Today I started to use this lib and have the following error:

PHP Notice: Undefined property: stdClass::$ToRecipients in Exchange-Web-Services-for-PHP/lib/ExchangeClient.php on line 257

Reviewing I found this code block:

if(!is_array($messageobj->ToRecipients->Mailbox)) {
    $messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
}

I see this object is referred in $messageobj in the line 241

$messageobj = $response->ResponseMessages->GetItemResponseMessage->Items->Message;

When I get all keys, I get this:

MimeContent
ItemId
Subject
Sensitivity
Body
Attachments
Size
DateTimeSent
DateTimeCreated
ResponseObjects
HasAttachments
IsReadReceiptRequested
From
IsRead

I suppouse my Exchange Server not send some propertyes like ToRecipients, fot this reason I suggest check is ToRecipients is set before process it like this:

if (isset($messageobj->ToRecipients)) {
    if(!is_array($messageobj->ToRecipients->Mailbox)) {
        $messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
    }
    
    foreach($messageobj->ToRecipients->Mailbox as $mailbox) {
        $newmessage->to_recipients[] = $mailbox;
    }
}

Instead

if(!is_array($messageobj->ToRecipients->Mailbox)) {
    $messageobj->ToRecipients->Mailbox = array($messageobj->ToRecipients->Mailbox);
}
foreach($messageobj->ToRecipients->Mailbox as $mailbox) {
    $newmessage->to_recipients[] = $mailbox;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant