Open quantrpeter opened 4 years ago
hi , trying to get all email, but EmailAddress field is null
$client = new Client($host, $username, $password, $version); $client->setTimezone($timezone); $client->setCurlOptions(array(CURLOPT_SSL_VERIFYPEER => false)); $request = new FindItemType(); $request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType(); $request->Traversal = ItemQueryTraversalType::SHALLOW; // Build the start date restriction. $greater_than = new IsGreaterThanOrEqualToType(); $greater_than->FieldURI = new PathToUnindexedFieldType(); $greater_than->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_DATE_TIME_RECEIVED; $greater_than->FieldURIOrConstant = new FieldURIOrConstantType(); $greater_than->FieldURIOrConstant->Constant = new ConstantValueType(); $greater_than->FieldURIOrConstant->Constant->Value = $start_date->format('c'); // Build the end date restriction; $less_than = new IsLessThanOrEqualToType(); $less_than->FieldURI = new PathToUnindexedFieldType(); $less_than->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_DATE_TIME_RECEIVED; $less_than->FieldURIOrConstant = new FieldURIOrConstantType(); $less_than->FieldURIOrConstant->Constant = new ConstantValueType(); $less_than->FieldURIOrConstant->Constant->Value = $end_date->format('c'); // Build the restriction. $request->Restriction = new RestrictionType(); $request->Restriction->And = new AndType(); $request->Restriction->And->IsGreaterThanOrEqualTo = $greater_than; $request->Restriction->And->IsLessThanOrEqualTo = $less_than; // Return all message properties. $request->ItemShape = new ItemResponseShapeType(); $request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES; // Search in the user's inbox. $folder_id = new DistinguishedFolderIdType(); $folder_id->Id = DistinguishedFolderIdNameType::INBOX; $request->ParentFolderIds->DistinguishedFolderId[] = $folder_id; $response = $client->FindItem($request); // Iterate over the results, printing any error messages or message subjects. $response_messages = $response->ResponseMessages->FindItemResponseMessage; foreach ($response_messages as $response_message) { // Make sure the request succeeded. if ($response_message->ResponseClass != ResponseClassType::SUCCESS) { $code = $response_message->ResponseCode; $message = $response_message->MessageText; fwrite( STDERR, "Failed to search for messages with \"$code: $message\"\n" ); continue; } // Iterate over the messages that were found, printing the subject for each. $items = $response_message->RootFolder->Items->Message; foreach ($items as $item) { $subject = $item->Subject; $id = $item->ItemId->Id; echo "from=".$item->From->Mailbox->Name."\n"; echo "from=".$item->From->Mailbox->EmailAddress."\n"; var_dump($item->From->Mailbox); echo "\t\t\t$subject\n"; } }
object(jamesiarmes\PhpEws\Type\EmailAddressType)#88 (5) { ["EmailAddress"]=> NULL ["ItemId"]=> NULL ["MailboxType"]=> string(6) "OneOff" ["Name"]=> string(10) "eTender 04" ["RoutingType"]=> NULL }
hi , trying to get all email, but EmailAddress field is null