1

I am using PHP-EWS to get a list of contact. This list of contact is a distribution list in the Contacts root folder.

Actually I am using this:

$ews = new ExchangeWebServices($server, $username, $password);


$request = new EWSType_FindItemType();

$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;

$request->ContactsView = new EWSType_ContactsViewType();
$request->ContactsView->InitialName = 'a';
$request->ContactsView->FinalName = 'z';


$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
 $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CONTACTS;

$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

$response = $ews->FindItem($request);

I am able to get the ID of the Distribution List, but I can't get the emails address in it. How could I get a stdClass Object of it or an array?

Laf
  • 7,965
  • 4
  • 37
  • 52
kbonnelly
  • 189
  • 1
  • 1
  • 11

1 Answers1

2

In order to get the contacts inside of a contact group, you need to use the ExpandDL operation, passing the item ID of the contact group you want to expand. I'm not familiar enough with the php-ews library to give you sample code, but hopefully this points you in the right direction. See this link for an example of what the SOAP request looks like.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • I'm trying to figure out how to make it work on php. Thanks, I'll let you know if it works! – kbonnelly Aug 21 '14 at 15:30
  • 2
    Good! It worked fine. Here is the code I used, in case someone had the same issue. $ews = new ExchangeWebServices($server, $username, $password); $request = new EWSType_ExpandDLType(); $request->Mailbox = new EWSType_EmailAddressType(); $request->Mailbox->ItemId = new EWSType_ItemIdType(); $request->Mailbox->ItemId->Id = $myDistributionListId; $response = $ews->ExpandDL($request); – kbonnelly Aug 21 '14 at 16:51