Using FindItems with EWSMA to display All Mail Items from an email

I would like to use the EWSMA to show all emails from a given user.  Currently my sample code just shows the emails from the given user in the Inbox and not the sub-folders.  How can I ensure that FindItems will search the subfolders as well?
Also, what is the property to check if the email is flagged in Outlook and on the Exchange Web App?  I am testing against an Office365 Exchange account.
private static void SearchItems()
ItemView iv = new ItemView(10);
FindItemsResults<Item> fiitems = _service.FindItems(WellKnownFolderName.Inbox, "from:[email protected]", iv);
foreach (Item item in fiitems)
Console.WriteLine("Subject:\t" + item.Subject);
Console.WriteLine("Received At:\t\t" + item.DateTimeReceived.ToString("dd MMMM yyyy"));
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();

Hi Luke,
while the EWS managed API indeed has a FindItems method which can search multiple folders at once, that method is marked internal. So, without some serious Reflection you won't be able to call it.
What you can do is call EWS directly. And you can combine it with the EWS managed API, to leverage AutoDiscover.
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1)
{Credentials = new NetworkCredential("username", "password")};
service.AutodiscoverUrl("mailaddress", url => true);
var binding = new ExchangeServiceBinding
Url = service.Url.ToString(),
Credentials = new NetworkCredential("user", "password")
var findItems = binding.FindItem(new FindItemType
ParentFolderIds = new[]
new
DistinguishedFolderIdType {Id = DistinguishedFolderIdNameType.inbox},
new
DistinguishedFolderIdType {Id = DistinguishedFolderIdNameType.sentitems},
Item =new
IndexedPageViewType { MaxEntriesReturned = 512, MaxEntriesReturnedSpecified
= true},
ItemShape = new
ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties},
The code above will search both, the Inbox and the SentItems folder.
As for the Flag: You'll have to access some extended properties here. See
http://msdn.microsoft.com/en-us/library/cc433487(v=EXCHG.80).aspx and
http://msdn.microsoft.com/en-us/library/cc433490(v=EXCHG.80).aspx for more details on this.
Kind regards,
Henning

Similar Messages

  • Display all valid items and select multiple items

    Let us say I have valid items in table. For each purchase user can select few items from the list. I have to display all valid items from table and user should able to check items to buy. What is the best way we can implement this in forms.
    Thanks, lalitha

    For all the valid items you can create LOV as i understood then user can choose what he wants. But this sentence ti still confusing to me. Or what is the tricky things in you scanerio if only you have to show the valid item then use LOV.
    Lalitk wrote:
    and user should able to check items to buy.-Ammad

  • How to display all tagged photos from the whole catalogue?

    Hi,
    I have been googleling around, but have not found the right information. I am trying to find all my tagged photos of all imported photos, but it would only show the tagged photos from a specific folder when I select that specific folder or from the timeline, in which I already knew that some tagged photos belong in those folders.
    My question is...how can I search tagged photos from the whole catalogue without going through the timeline or clicking each folder and subfolder to view them. I would like that the organizer display all tagged items from all my folders and subfolders at once.
    Sorry if this has been answered and I was not able to find the right forum or information.
    Many thanks in advance!
    Dreamy

    Thanks a lot!

  • I seem to have lost the All Mail facility in my email boxes. How can I restore this.have a feelin the grandchildren played with it.

    I seem to have lost the All Mail facility in my email boxes. How can I restore it. Have a feelin the grandchildren have played with it.
    Thanks

    That is strange. As far as I know, the "All Mail" facility is unique to Gmail and Gmail-based mail accounts, and it cannot be removed from those accounts.
    Are you in fact using a Gmail account?

  • I have had my apple tv 2 for about 3 months which work perfectly fine when I use it with my iPad 3 ー all of the sudden I get the HDCP Error!  I read the forms and done everything!  Apple I name a loyal customer, please come out with an update soon!

    I have had my apple tv 2 for about 3 months which work perfectly fine when I use it with my iPad 3 ー all of the sudden I get the HDCP Error!  I read the forms and done everything!  Apple I name a loyal customer, please come out with an update soon!

    That's one of the weird things.. it recognizes it maybe 10% of the time. And usually, only after I do the two-button reset. Problem is.. since it won't charge above 2%, anytime I try to do a restore or anything like that using iTunes, my device shuts off and I lose whatever progress I'd made.
    So, an update... after reading through a bunch of similar complaints (there are literally 1000's of them so there's NO WAY this isn't somehow ios7 related, thanks a lot APPLE ) I decided to try a restore in recovery mode. After 3 hours and several disconnections... I ended up having to just set it up as a new iPad, as the restore did nothing. Weirdly though... as I was doing the restore in recovery mode.. I noticed I'd gotten up to a 10% charge.. higher than it's been since September, so after setting it up as a new device, I turned it off and plugged it in using the wall charger. 2 hours later and I was up to 38%. Still not great, as my iPad, before ios7 could've fully charged twice in the amount of time it took for me to now get 28% more of a charge. And that's with a fully cleaned out device.. so that really ***** and I'm now more confused than ever.
    But I'm gonna leave it overnight charging and see what I come up with tomorrow. Sadly, when I paid $600 for it in February, I never expected to have to play "wait and see" with it...

  • Reg: Displaying all the items of main window in the same page itself.

    All,
    I am developing an SAp Script form which is using five windows. Out of which third window is the main window. In the main window i am displaying details of item sold. The form prints perfectly when the number of items is with in the limit of the main window height. When it exceeds the main window height a second page with the same format of the first page is displayed with the remaining items in main window. ie 1,2,4,5 window is repeated in both pages.
    I want to display all the items of the main window in the first page itsel and if it exceeds first page show the remainng items in the next page and then display 4th and 5th window. IS it posiible using SAp script. Am i to do some configuration for this?
    Note: I have assigned Next page to first page itself.

    Thanks Anji.
    I understood about display of first and second windows.
    About main window and Fourth and Fifth window i still have doubt. I have given specific height to main window and after that put the fourth and fifth window with specific height in first page itself. So what happens is that When mainwindow overflows it will print up to specified height in the first page. Then prints the Fourth and Fifth window in first page. Then it goes to second window prints the remaining items in main window then again displays fourth and fifth window. Could you please find a solution for this too.
    Regs
    Rakesh

  • I am using Iphone with windows. I have draged photos from my computer into Iphone in the past, but cant seem to do it now. How do I move photos from my pc to my iphone without deleting photos that are on the phone.

    I am using Iphone with windows. I have draged photos from my computer into Iphone in the past, but cant seem to do it now. How do I move photos from my pc to my iphone without deleting photos that are on the phone.

    You cannot drag pics from computer to iphone.  This has never been a feature of iphone.
    You sync them as you would anything esle.
    You select photos from the photos tab.  Whatever is selected will be on your iphone.  Anything not selected will not be. Make sure that everything you want on your iphone is selected, then sync.

  • How do you reduce the size of the email storage on an iPhone?  I have deleted all mail items and my mailbox still takes up 1.2 GB of space.

    how do you reduce the size of the email storage on an iPhone?  I have deleted all mail items and my mailbox still takes up 1.2 GB of space.

    What is the Other on my iPhone and How to Remove It
    Also
    "First you go settings/general/usage/music/then left swipe over music and press delete and you would think it deletes your music but it doesn't instead it deletes your other but make sure your ipod is connected to a computer while doing this"
    as recommended by:
    How do I get rid of "other" storage: Apple Support Communities
    Next, usually restoring from backup eliminated the corrupted files. However, sometimes restoring to factory settings/new iPod is required.
    To restore from backup see:
    iOS: How to back up
    To restore to factory settings/new iPod see:
    iTunes: Restoring iOS software

  • HT201342 I set up my aged fathers iPAD using may account but changed his e-mail account from mine to another I set up for him.Now whenever my sister sends him an e-mail via icloud it appears that it is sent from me.how can I rectify this

    I set up my aged fathers iPAD using may account but changed his e-mail account from mine to another I set up for him.Now whenever my sister sends him an e-mail via icloud it appears that it is sent from me.how can I rectify this

    search google for "iphone remove picture from contact"

  • Can one use a iPod classic to restore all the songs from a crashed pc onto an iMac '12?

    Can one use a iPod classic to restore all the songs from a crashed pc onto an iMac '12?

    Yes
    Put all the music on one computer, make sure it is authorized for all accounts, sync.

  • When I sync with my iPad2, not all playlists come from my computer to the ipad - why?

    When I sync with my iPad2, not all playlists come from my computer to the ipad - why?

    Try deleting the photo cache from your computer and then re-try the photo sync and see if they then copy over correctly - the location of the cache, and how to delete it, is on this page http://support.apple.com/kb/TS1314

  • Moving Mail Items from Outlook through VBA to PST files

    Can anyone help me to move mail item (from Inbox) to PST files using VBA?
    Can this be achived?

    Per our support engineer:
    This Visual Basic for Applications (VBA) example uses GetDefaultFolder to return the MAPIFolder object that represents the default folder. It then uses the Find and FindNext methods to find all messages sent by Dan Wilson and uses the Move method to move all e-mail messages sent by Dan Wilson from the default Inbox folder to the Personal Mail folder. To run this example without any errors, replace 'Dan Wilson' with a vaid sender name and make sure there's a folder under Inbox called 'Personal Mail'. Note that myItem is declared as type Object so that it can represent all types of Outlook items including meeting request and task request items.
    Sub MoveItems()
             Dim myOlApp As New Outlook.Application
             Dim myNameSpace As Outlook.NameSpace
             Dim myInbox As Outlook.MAPIFolder
             Dim myDestFolder As Outlook.MAPIFolder
             Dim myItems As Outlook.Items
             Dim myItem As Object
             Set myNameSpace = myOlApp.GetNamespace("MAPI")
             Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
             Set myItems = myInbox.Items
             Set myDestFolder = myInbox.Folders("Personal Mail")
             Set myItem = myItems.Find("[SenderName] = 'Dan Wilson'")
             While TypeName(myItem) <> "Nothing"
                     myItem.Move myDestFolder
                     Set myItem = myItems.FindNext
             Wend
    End Sub
    If you use Microsoft Visual Basic Scripting Edition (VBScript) in a Microsoft Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.
    Set myNameSpace = Application.GetNameSpace("MAPI")
    Set myInbox = myNameSpace.GetDefaultFolder(6)
    Set myItems = myInbox.Items
    Set myDestFolder = myInbox.Folders("Personal Mail")
    Set myItem = myItems.Find("[SenderName] = 'Dan Wilson'")
    While TypeName(myItem) <> "Nothing"
        myItem.Move myDestFolder
        Set myItem = myItems.FindNext
    Wend
    ==================================
    And here is another Sample code you can refer
    Outlook VBA Code. Move old mails from Send to an archive PST
    http://blogger.xs4all.nl/borstr/archive/2006/02/09/77804.aspx
    -brenda (ISV Buddy Team)

  • How to get all checked items from TreeView in VC++ mfc

    void CPDlg::OnTreeClk(NMHDR *pNMHDR, LRESULT *pResult)
    NMTREEVIEW& nm = *(LPNMTREEVIEW)pNMHDR;
    // which item was selected?
    HTREEITEM hItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    temp = m_columnTree.GetItemText(hItem, 0);
    MessageBox(temp);
    if (!hItem) return;
    // the rest of processing code..
    I'm new in VC++ .
    this code gives only current selected item . but i need to get all checked items from treeView.
    kindly help me..

    no not unchecked .. the all check box's gone from tree view. which means Treeview without check box.
    finally i tried SetCheck 
    void CPracticesDlg::OnSelchangedTreectrl(NMHDR* pNMHDR, LRESULT* pResult)
    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here
    tree_state = 1;//changed
    HTREEITEM hItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    BOOL chk = m_columnTree.GetTreeCtrl().GetCheck(hItem);
    if (chk == TRUE)
    HTREEITEM hmyItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    // Check all of the children of hmyItem.
    if (m_columnTree.GetTreeCtrl().ItemHasChildren(hmyItem))
    HTREEITEM hNextItem;
    HTREEITEM hChildItem = m_columnTree.GetTreeCtrl().GetChildItem(hmyItem);
    while (hChildItem != NULL)
    hNextItem = m_columnTree.GetTreeCtrl().GetNextItem(hChildItem, TVGN_NEXT);
    m_columnTree.GetTreeCtrl().SetCheck(hChildItem, 1);
    hChildItem = hNextItem;
    else
    HTREEITEM hmyItem = m_columnTree.GetTreeCtrl().GetSelectedItem();
    // Uncheck all of the children of hmyItem.
    if (m_columnTree.GetTreeCtrl().ItemHasChildren(hmyItem))
    HTREEITEM hNextItem;
    HTREEITEM hChildItem = m_columnTree.GetTreeCtrl().GetChildItem(hmyItem);
    while (hChildItem != NULL)
    hNextItem = m_columnTree.GetTreeCtrl().GetNextItem(hChildItem, TVGN_NEXT);
    m_columnTree.GetTreeCtrl().SetCheck(hChildItem, 0);
    hChildItem = hNextItem;
    code works good . but here is i think small problem . i cant find it.
    when i click the root node it goes to checked state but not child node. again i click same root node it goes to unchecked state but all child's are goes to checked state.
    help me. here what is the problem?

  • When I send a text using siri the recipient shows that the text came from my email. How do I fix that so it show that the text came from my phone number and not my email address?

    When I send a text using siri the recipient shows that the text came from my email. How do I fix that so it show that the text came from my phone number and not my email address?

    Settings > Messages > Send & Receive > Start new conversations from:
    Only your phone number is selected.

  • ICal keeps sending email notifications from all agenda items from the last 2 years. After laptop start up this action is repeated every hour. How can I stop these 300 emails coming in every hour?

    iCal keeps sending email notifications of all agenda items from the last 2 years (then I bought my laptop). After laptop start up this action is repeated every hour. How can I stop these >300 emails coming in every hour?

    Hi,
    We have rolled out a fix for this issue.
    Please log off and log back in to your machine and the issue should be resolved automatically. In case that does not work, please manually run the msi installer posted here (may require reboot).
    For details, please refer to the KB article here: Multiple RunOnce keys created 11.0.10 and 10.1.13 Acrobat | Reader
    Please let us know if you still face any issues.
    Thanks,
    Ashu Mittal

Maybe you are looking for

  • Report RPTIME00 error

    Hi! I have an employee with infoset 0007: Start: 01.07.2011 Time Mgmt status:  1-Time Evaluation of actual times The status infoset 0003 is in time evaluation section: Earl.pers.rec.date   01.07.2011   Pers.calendar from   01.01.2012 PDC recalculatio

  • How can run the report SAP_INFOCUBE_DESIGN?

    hI gURUS To know about the DIM Table size How can run the report SAP_INFOCUBE_DESIGN? Thanks Cheers Durai

  • Parameters prompts& default

    Hello all, Have 2 questions regarding parameter fields: (1) Regarding static parameter: Is it possible to import field values directly from the DB?     After I select <Action>-->"Append all DB values" nothing is added to value field? (2) I have appli

  • How can u know the process chain total time, individual time?

    Hi guru's How can u know the process chain total time, individual time? and what options will available in sm37? Thanks prabha reddy

  • Why can't i buy iphone from the usa website?

    i've been trying to buy an iphone from the usa website as a gift to my sister who lives there... but it doesn't accept my postcode.. is it not possible to buy an iphone from uk?