php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

Issue with using toRecipients property in EWS restriction

Open hmsfdev opened this issue 1 year ago • 2 comments

I am currently working with Exchange Web Services (EWS) in PHP and I have encountered an issue with using the toRecipients property in the restriction. I have successfully used other properties such as From in the restriction and it works fine. However, when I try to use the toRecipients property, I receive the following error message: "An error occurred: The property can not be used with this type of restriction."

Here is an example of the working restriction using the From property

$restriction = [
    'And' => [
        'And' => [
            'IsEqualTo' => [
                'From' => $email_search,
            ]
        ]
    ]
];

However, when I try to use the toRecipients property in the same way, like this:

$restriction = [
    'And' => [
        'And' => [
            'IsEqualTo' => [
                'toRecipients' => $email_search,
            ]
        ]
    ]
];

. I even tried putting $email_search in an array, but I encounter the error: "Array to string conversion"

I have searched for a solution but haven't found any specific information on using the toRecipients property in EWS restrictions. I would greatly appreciate any guidance or insights on how to properly use the toRecipients property in the restriction.

Thank you in advance for your help.

hmsfdev avatar Jul 20 '23 19:07 hmsfdev

I've never used restrictions with EWS, but maybe the error is that you need to use 'ToRecipients' instead of 'toRecipients' as you can see on this documentation :

$restriction = [
    'And' => [
        'And' => [
            'IsEqualTo' => [
                'ToRecipients' => array('[email protected]', '[email protected]'), //Or your array $email_search
            ]
        ]
    ]
];

Or maybe something like that :

$restriction = [
        'And' => [
            'IsEqualTo' => [
                'ToRecipients' => array('[email protected]', '[email protected]'), //Or your array $email_search
            ]
        ]
];

Matt504 avatar Jul 24 '23 07:07 Matt504

I've never used restrictions with EWS, but maybe the error is that you need to use 'ToRecipients' instead of 'toRecipients' as you can see on this documentation :

$restriction = [
    'And' => [
        'And' => [
            'IsEqualTo' => [
                'ToRecipients' => array('[email protected]', '[email protected]'), //Or your array $email_search
            ]
        ]
    ]
];

Or maybe something like that :

$restriction = [
        'And' => [
            'IsEqualTo' => [
                'ToRecipients' => array('[email protected]', '[email protected]'), //Or your array $email_search
            ]
        ]
];

Hello

thanks you for helping , but this code give me Array to string conversion..

hmsfdev avatar Aug 30 '23 08:08 hmsfdev