Outlook 2010 Select a folder in a user account

Nico1000

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
I have a macro that runs correctly but I must first select the user account name 'blabla@blabla.com' and then select the folder 'Invoices' in that account prior to running the macro. I am struggling to add vba code in the macro that would automatically select the user account and folder first and then run the rest of the code in the macro. (run it by clicking a button on ribbon from any account)

Any help would be greatly appreciated.

Thank you.

-Nico
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Depends on whether or not the mailbox is added to your profile. If it is, that is if you can see the mailbox name and its subfolders in the folder explorer (ctrl+6), then this would work, assuming that "invoices" is a subfolder of the inbox:
set folder=application.session.folders("enter mailbox name here").folders("inbox").folders("invoices")

If the mailbox is not added, do it this way, again assuming invoices is a subfolder of the inbox:
dim r as recipient
set r=application.session.createrecipient("enter address here")
set folder=application.session.getsharedefaultfolder(r,olfolderinbox)
set folder=folder.folders("invoices")
 

Nico1000

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Depends on whether or not the mailbox is added to your profile. If it is, that is if you can see the mailbox name and its subfolders in the folder explorer (ctrl+6), then this would work, assuming that "invoices" is a subfolder of the inbox:
set folder=application.session.folders("enter mailbox name here").folders("inbox").folders("invoices")

If the mailbox is not added, do it this way, again assuming invoices is a subfolder of the inbox:
dim r as recipient
set r=application.session.createrecipient("enter address here")
set folder=application.session.getsharedefaultfolder(r,olfolderinbox)
set folder=folder.folders("invoices")
Thank you sir.
 
Top