none
Need to select non default email account RRS feed

  • Question

  • Hi,

    In an outlook 2010 set up I have connected multiple email accounts to a single Outlook, from Yahoo, Hotmail and Att etc... each account have their own boxes data and work independently... I have a VBA Script that should only run on a single account as the emails are coming in... So I use:

    Set objFolder = ns.GetDefaultFolder(olFolderInbox)  to get to the inbox...

    Problem is if I change the Default email to another email account, My VBA script does not run... Any idea how I can select Inbox of a None Default email on an Outlook that is handing multiple email accounts?

    Regards,

    Jeff P.


    Jeff Paarsa

    Friday, January 3, 2014 9:33 PM

Answers

  • You can use Namespace.Stores collection and Store.GetDefaultFolder.

    In case of C++ or Delphi, you can use the IOlkAccountManager interface to read the entry id of the folder where a particular account delivers to.

    For accounts that can deliver to an arbitrary folder in any store (such as POP3/SMTP accounts), if using Redemption is an option, you can use RDOPOP3Account.DeliverToFolder and RDOEASAccount.DeliverToFolder properties.


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


    Friday, January 3, 2014 9:53 PM
  • Hi Jeff,

    As Dmitry suggested, you need to use the GetDefaultFolder of the Store class (not Namespace) to get the default folder in the store and that is of the type specified by the FolderType argument. MSDN provides the following description:

    This method is similar to the GetDefaultFolder method of the  NameSpace object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

    Finally, be aware that the method was added in Outlook 2010, i.e. it is not available in earlier Outlook versions.

    Saturday, January 4, 2014 2:02 PM
  • Hi Jeff,

    The NameSpace class provides the Stores property which returns a collection object that represents all the Store objects in the current profile. You can iterate over all stores and call the GetDefaultFolder method. Please find a sample code in the similar forum thread.

    Saturday, January 4, 2014 4:29 PM

All replies

  • You can use Namespace.Stores collection and Store.GetDefaultFolder.

    In case of C++ or Delphi, you can use the IOlkAccountManager interface to read the entry id of the folder where a particular account delivers to.

    For accounts that can deliver to an arbitrary folder in any store (such as POP3/SMTP accounts), if using Redemption is an option, you can use RDOPOP3Account.DeliverToFolder and RDOEASAccount.DeliverToFolder properties.


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


    Friday, January 3, 2014 9:53 PM
  • Hi Jeff,

    As Dmitry suggested, you need to use the GetDefaultFolder of the Store class (not Namespace) to get the default folder in the store and that is of the type specified by the FolderType argument. MSDN provides the following description:

    This method is similar to the GetDefaultFolder method of the  NameSpace object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

    Finally, be aware that the method was added in Outlook 2010, i.e. it is not available in earlier Outlook versions.

    Saturday, January 4, 2014 2:02 PM
  • Hi,

    Yes I do have Office 2010 and my script runs on 2010... But I did a search for

    Store.GetDefaultFolder

       Method and I could not find or get hit on a sample code on how it is being done... Can you guide me to a sample code to see how it is done?  My knowledge and books are a little rusty goes back to 2007, 2003... 

    Regards,

    Jeff P.



    Jeff Paarsa

    Saturday, January 4, 2014 3:58 PM
  • Hi Jeff,

    The NameSpace class provides the Stores property which returns a collection object that represents all the Store objects in the current profile. You can iterate over all stores and call the GetDefaultFolder method. Please find a sample code in the similar forum thread.

    Saturday, January 4, 2014 4:29 PM
  • Thanks a lot... I will look into that...

    Jeff Paarsa

    Saturday, January 4, 2014 7:35 PM