none
Advanced search on additional mailboxes in winforms C# RRS feed

  • Question

  • HI All,

          I am trying to do an advanced search on additional mailbox for which i have access. I was able to do this successfully in asp.net but in winforms it just hangs. I am able to search successfully my inbox and subfolders. My piece of code is

    Namespace object ns is initialized in form_load itself.

    folderInbox = ns.Folders[ddlSelectInbox.SelectedItem].Folders["Inbox"];

    scope = "'" + folderInbox.FolderPath + "'";

    advancedSearch = outlookapp.AdvancedSearch(scope,filter,true);

    it just hangs after the advancedSearch and does not even go into advancedSearchComplete. This is happening only in winforms that too for additional mailboxes but it works sucessfully in asp.net . Can some one help me on this ?

    Thanks,

    Prathima

    
    
    Wednesday, April 16, 2014 12:28 AM

Answers

All replies

  • You actually used Outlook in ASP.Net? This is a very bad idea...

    I can speculate that the delegate mailbox is opened in the online (as opposed to cached) mode, and the online Exchange store does not raise quite a few events for the performance reasons.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, April 16, 2014 1:32 AM
  • Hi There,

      Thanks for the response . Then is there no other way can I do advanced search on additional mailboxes in winforms c# ?

    Wednesday, April 16, 2014 1:36 AM
  • If you are only searching in one folder, why not use MAPIFolder.Items.Find/FindNext/Restrict?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, April 16, 2014 1:38 AM
  • Hi Dmitry,

         I have checked the advanced settings of my additional mail box the additional mailboxes are opened using Cached Exchange Mode. As i see this option is ticked. My question here is why am able to do this advanced search in asp.net but not in winforms.Am trying to access the same outlook instance from both the applications.

    Wednesday, April 16, 2014 1:44 AM
  • Firstly, the biggest question is why it ever worked in ASP.Net. I cannot stress this enough - do not do that. If you have production code that invokes OOM from ASP.Net, get rid of it NOW, before it blows up at the worst possible moment.

    Secondly, was that mailbox already added as a delegate mailbox on the Advanced tab of the Exchange service options dialog? Or did you open it using Namespace.GetSharedDefaultFolder?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, April 16, 2014 2:37 AM
  • Hi Dmitry,

            Forget about ASP.net for now i dont have any code in production. For Second thing the mailbox was already added in the advanced tab of the exchange service options dialog.I am getting that list of mailboxes into a combox box and based on the selected mailbox am doing the advanced search. The requirement for me is that user should be able to select the mailbox (if he has any additional mailbox in his outlook) and proceed accordingly.

    Thanks,

    Prathima

    Wednesday, April 16, 2014 2:54 AM
  • Do you see the fnevSearchComplete MAPI notification in OutlookSpy (http://www.dimastr.com/outspy) (click IMsgStore button, go to the IMsgStore::Advise tab) if you create advanced search programmatically or invoke Advanced Find througt the Outlook UI?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Wednesday, April 16, 2014 5:59 AM
  • Hello Prathima,

    Please take a look at the Advanced search in Outlook programmatically: C#, VB.NET article. It provides a sample code for VSTO based add-ins. I'd recommend to test the sample code to be sure that the issue is not related to other factors such as filter or scope incorrect declaration.

    Also, as a workaround, you may consider using the Restrict or Find/FindNext methods instead of advanced search. You can read more about these methods in the following articles:

    How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)

    How To: Use Restrict method to retrieve Outlook mail items from a folder

    Finally, the Considerations for server-side Automation of Office article states the following:

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    I.e. you shouldn't automate Outlook from ASP.NET.

    Wednesday, April 16, 2014 12:06 PM