Select a folder in a user account

Status
Not open for further replies.

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.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
H Select Specific Account When Sending Email, Based on Current Folder Outlook VBA and Custom Forms 1
S Display PF contact folder items to select contact to link to appointment Outlook VBA and Custom Forms 1
F Why do messages only arrive when I select the server's folder? Using Outlook 3
C Select folder to file send emails Using Outlook 1
P Blank list in "Select Destination Folder" when importing contacts to Outlook 2003 Using Outlook 1
M How to programmatically select a outlook search folder? Outlook VBA and Custom Forms 1
R select folder as addressbook Outlook VBA and Custom Forms 1
S Select a folder in Outlook (in code) Outlook VBA and Custom Forms 2
R Add 'Company' to Select Names Form Using Outlook 1
B Select / activate first email item in the searched query Using Outlook 1
A Multi-select Listbox Outlook VBA and Custom Forms 6
N Auto-complete - block select emails Using Outlook 3
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
Diane Poremsky Select from a List of Subjects before Sending a Message New Slipstick.com Articles 0
Diane Poremsky Select Multiple Calendars in Outlook New Slipstick.com Articles 0
P Select image in contact notes field and save as jpg Outlook VBA and Custom Forms 6
oliv- How to select an mailitem in explorer with "show as conversation" Outlook VBA and Custom Forms 8
N Select Existing BCM Business Contact in C# application Using Outlook 0
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
B What is the best way to use Outlook address book to select customer and then open Excel Outlook VBA and Custom Forms 22
C Outlook 2007 Select Names Default columns Using Outlook 3
R Can BCM monitor and select specific emails and use content info to update the client's record? BCM (Business Contact Manager) 1
R Cannot select iCloud calendar Using Outlook 5
H Select one of Contact-Mailadesses to Export > Excel or Winword Outlook VBA and Custom Forms 2
G Select Outlook account for BCM? BCM (Business Contact Manager) 2
Z Manual archive of select folders Using Outlook 1
R How to modify Outlook Select Rooms form columns Using Outlook 1
Z bulk add categories / with fixed colours / select multiple categories on a not Using Outlook 1
C Outlook editing won't select just one word Using Outlook 1
I Address book contacts not listed in "Select Names:Contacts" window Using Outlook 2
Y Outlook 2010 Select and reply to multiple messages at one time Using Outlook 0
Y Outlook 2010 Select and reply to multiple messages at one time Using Outlook 2
D Contacts as default in Select Names dialog Using Outlook 1
D How to select different account when sending emails from Outlook 2003 Using Outlook 3
E Outlook 2010 calendar print - select begin-end weeks for month print but Preview and print show ful Using Outlook 2
R Select contacts and print labels for selected contacts from complete contact list in Outlook. Using Outlook 1
P Sharing Outlook contacts so users can select as an address book for email. Using Outlook 1
B Do not allow / Show to select "Tentative" option in Responce Using Outlook 1
H Exchange Server 2007 strips messages when clients select add item in a new Message Using Outlook 10
R Cannot select items from Outlook 2007 Menu bars Using Outlook 1
D Outlook 2010 crashes when I select new message, reply, forward or send as attachment Using Outlook 3
M Not able to select my contacts list for my address book Using Outlook 7
L Rule to select incoming messages by contact category Using Outlook 11
G MS Exchange ActiveSync 2007 Denying Select Devices Exchange Server Administration 2
D Select categories to print Using Outlook 1
C Error when trying to select the Email Auto link option Using Outlook 2
N Not able to select the details of a head office synced contact Exchange Server Administration 4
Z "Select Names: Contacts" Menu displays contacts in different ways Using Outlook 6
Similar threads


















































Top