Garethp / php-ews

PHP Exchange Web Services
BSD 3-Clause "New" or "Revised" License
112 stars 45 forks source link

Loading the Email-Signature in office365 Outlook #223

Open basementmedia2 opened 2 years ago

basementmedia2 commented 2 years ago

Hi Gareth,

our company switched over to outlook365 onlione exchange server. Everything still works fine with your library except loading the email-signature.

on the old Email Server, this worked:

require_once "vendor/autoload.php";

use garethp\ews\API;
use garethp\ews\API\Message\GetUserConfigurationType;
use garethp\ews\API\Enumeration\DistinguishedFolderIdNameType;
use garethp\ews\API\Enumeration\ResponseClassType;
use garethp\ews\API\Enumeration\UserConfigurationPropertyType;
use garethp\ews\API\Type\DistinguishedFolderIdType;
use garethp\ews\API\Type\UserConfigurationNameType;

$client = API::withUsernameAndPassword("outlook.office.com", "myusername", "mypassword"); // NEW CONNECTION
//$client = API::withUsernameAndPassword("owa.mycompany.de", "myusername", "mypassword"); // THIS WAS THE OLD CONNECTION

$request = [
    'UserConfigurationName' => [
        'Name' => 'OWA.UserOptions',
        'DistinguishedFolderId' => ['Id' => DistinguishedFolderIdNameType::ROOT]
    ],
    'UserConfigurationProperties' => UserConfigurationPropertyType::ALL
];

$response = $client->getClient()->GetUserConfiguration($request);
$uconfname=$response->getDictionary()->DictionaryEntry;

for ($i=0; $i<count($uconfname); $i++) {

    $entry=$uconfname[$i]->getDictionaryKey()->getValue();

    if ($entry=="signaturehtml") {
        $signatur=$uconfname[$i]->getDictionaryValue()->getValue();
    }
}

echo $signatur;

I think this is the problem:

'Name' => 'OWA.UserOptions',

but what's the correct Object to replace here?

Would be great to hear from you. Best wishes

Daniel