none
VSTO Sent Items folder specific to an account RRS feed

  • Question

  • Hi ,

    I have multiple outlook accounts configured on my system

    following code returns me items from top most accounts.  

    Outlook.MAPIFolder folder = this.Application.ActiveExplorer().Session.
                GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
                Outlook.Items sendItems = folder.Items;

    how to get sentItems related to an specific account?

    Kind Regards

    Harish

    Friday, December 27, 2019 11:25 AM

All replies

  • Firstly, there is absolutely no reason to use ActiveExplorer in this.Application.ActiveExplorer().Session - ActiveExplorer can return null. You can shorten it to this.Application..Session.

    Secondly, use Store.GetDefaultFolder instead of Namespace.GetDefaultFolder. You can retrieve the Store object either from the Namespace.Stores collection or from MAPIFolder.Store. E.g the currently selected store is (no error checking) this.Application.ActiveExplorer().CurrentFolder.Store.


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

    Friday, December 27, 2019 5:04 PM