Open PeteKraft opened 4 years ago
I'm not sure where to look next, I simply can not get this to work. If anybody has any tips, I'd be very greatful.
In brief, I'm working with a Public Folder that holds all the company's contacts. I need to find a way to update certain contacts. I did find the example here, but the example does not search for an existing contact, it just updates the first contact it finds.
If I have an email address, or just a name, how can I perform a search inside a Public Folder to retrieve the ID, so I can use the ID to update the contact ?
Here's my complete code :
require_once '../../common/vendor/autoload.php';
use garethp\ews\API as API;
use garethp\ews\API\Enumeration;
use garethp\ews\API\Type;
// exchange login info
$host = 'xxx';
$username = 'xxx';
$password = 'xxx';
$api = API::withUsernameAndPassword($host, $username, $password);
$folder = $api->getFolderByDisplayName('Clients Folder', Enumeration\DistinguishedFolderIdNameType::PUBLICFOLDERSROOT);
$request = [
'Traversal' => 'Shallow',
'ItemShape' => [
'BaseShape' => 'Default',
],
'ParentFolderIds' => [
'FolderId' => $folder->getFolderId()->toXmlObject()
],
'IndexedPageItemView' => ['MaxEntriesReturned' => 10, 'Offset' => 0, 'BasePoint' => 'Beginning'],
'Restriction' => [
[
'IsEqualTo' => [
[
'FieldURI' => ['FieldURI' => 'contacts:EmailAddresses'],
'FieldURIOrConstant' => ['Constant' => ['Value' => 'john@doe.com']]
]
]
]
]
];
$request = Type::buildFromArray($request);
$response = $api->getClient()->FindItem($request);
echo "<pre>";
var_dump($response);
echo "</pre>";
This code just returns every contact it finds, it seems that the restriction is not taken into account.
I also tried with the ResolveNames function, but this only works on local folders, not public folders.
Any help is really, really appreciated.
I have a database of +20k contacts stored in Public Folders. I can access all the info, but is there a way that I can pull all information from 1 certain contact ?
I have tried this :
Looking at the getContacts, it seems this is not supported.
Might there be a better way to get all info related to one certain person ?