Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can search in Subfolders? #226

Closed
nguaman opened this issue Dec 12, 2014 · 1 comment
Closed

How I can search in Subfolders? #226

nguaman opened this issue Dec 12, 2014 · 1 comment

Comments

@nguaman
Copy link

nguaman commented Dec 12, 2014

I have a shared folder with subfolders, and I am trying to search a string in the subject of each email, that works ok, but only if the email is allocated in the inbox root.

  • Inbox Root
    • new
    • queue
    • completed

but if the email is allocated in some of the subfolder (new,queue,compelted), I get a error .

how I can search more deeper? (search in subfolder)

this is my code.

$ews = new ExchangeWebServices($host, $username, $password, ExchangeWebServices::VERSION_2010);

$request = new EWSType_FindItemType();

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

$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

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

$request->IndexedPageItemView = new EWSType_IndexedPageViewType();
$request->IndexedPageItemView->MaxEntriesReturned = 25;
$request->IndexedPageItemView->BasePoint = 'Beginning';
$request->IndexedPageItemView->Offset = 0;

$EmailAddy = "email@email.com";

$mailBox = new EWSType_EmailAddressType();
$mailBox->EmailAddress = $EmailAddy;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox = $mailBox;
$folder_id = 'folder.id';

$request->ParentFolderIds->FolderId = new EWSType_FolderIdType();
$request->ParentFolderIds->FolderId->Id = $folder_id;

$request->Restriction = new EWSType_RestrictionType();
$request->Restriction->Contains = new EWSType_ContainsExpressionType();

$request->Restriction->Contains->FieldURI = new EWSType_PathToUnindexedFieldType();
$request->Restriction->Contains->FieldURI->FieldURI = 'item:Subject';

$request->Restriction->Contains->Constant = new EWSType_ConstantValueType();
$request->Restriction->Contains->Constant->Value = 'value-to-search-in-the-subject'

$request->Restriction->Contains->ContainmentComparison = new EWSType_ContainmentComparisonType();
$request->Restriction->Contains->ContainmentComparison->_ = EWSType_ContainmentComparisonType::IGNORE_CASE;

$request->Restriction->Contains->ContainmentMode = new EWSType_ContainmentModeType();
$request->Restriction->Contains->ContainmentMode->_ = EWSType_ContainmentModeType::SUBSTRING;

$request->SortOrder = new EWSType_NonEmptyArrayOfFieldOrdersType();
$request->SortOrder->FieldOrder = array();
$order = new EWSType_FieldOrderType();

$order->FieldURI->FieldURI = 'item:DateTimeReceived';
$order->Order = 'Ascending';
$request->SortOrder->FieldOrder[] = $order;

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

@jamesiarmes
Copy link
Owner

This issue is two years old. If you are still having trouble with the latest version from master, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants