Lylo
Lylo

Reputation: 1261

How do you to retrieve attendees with php-ews

This is the code that i'm using which works perfectly. The only thing that i'm struggling with is getting the attendees information

$request = new EWSType_FindItemType();
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

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

$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate = date('c', strtotime('01/01/2015 -00'));
$request->CalendarView->EndDate = date('c', strtotime('01/31/2016 -00'));

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



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


if ($response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView > 0){
        $events = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
        foreach ($events as $event){
var_dump($event);
}

Upvotes: 1

Views: 861

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

The Attendees, Body of the Appointment and a number of other properties aren't returned via the FindItems operation see https://msdn.microsoft.com/en-us/library/bb508824.aspx. So you will need to make a GetItem request on the Appoointment as well eg

foreach ($events as $event) {
    $request = new EWSType_GetItemType();
    $request->ItemShape = new EWSType_ItemResponseShapeType();
    $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
    $request->ItemShape->BodyType = EWSType_BodyTypeResponseType::HTML;
    $request->ItemIds = new EWSType_NonEmptyArrayOfBaseItemIdsType();
    $request->ItemIds->ItemId = array();
    $event_item = new EWSType_ItemIdType();
    $event_item->Id = $event->ItemId->Id;
    $request->ItemIds->ItemId[] = $event_item;
    $response = $ews->GetItem($request);
    var_dump($response)
}

Cheers Glen

Upvotes: 1

Related Questions