VBA to choose Outlook Profile

vinz4ever

New member
Local time
Today, 19:31
Joined
May 1, 2012
Messages
7
Hi,

I've got VBA to open Outlook and create an email but as i have 3 different Outlook profiles i need code that automatically selects the profile.

On a button, once that is pressed it opens an email with pre written text then sends it but then closes Outlook and reopens outlook, but this time i need it to pick a different profile in which another message is created and sent.

What can i do to make it pick a particular profile then close Outlook and then open Outlook and pick a different profile?

Thanks
 
I know this is an old thread, but I just wanted to clean it up and answer it for next time.

The answer is to us the LOGON method of the MAPI object in Outlook.
Here is a link to the full explanation.
http://msdn.microsoft.com/en-us/library/office/ff861594.aspx

Below is an example of logging on to the default profile with NO dialog.
Code:
Dim olApp As Outlook.Application
Dim oNS As Outlook.Namespace
Set olApp = GetObject(, "Outlook.Application")
Set oNS = olApp.GetNamespace("MAPI")
oNS.Logon "", "", False, True

If you change that "False" to a true then you should get a dialog and you can then choose your profile.
 
if the code does not open outlook express what would the tweek be to make it open outlook express?

thanks smiler44
 
an alternative way would be to use the /profile profilename switch if the profile is known. Not sure if this will work with the code from darbid, but it will work with the SHELL() function. EG to open outlook at the vinz4ever profile use outlook.exe/ profile "vinz4ever" so

Code:
x=SHELL("\\path to outlook\outlook.exe/ profile "vinz4ever")
 

Users who are viewing this thread

Back
Top Bottom