Way to Specify Profile for Outlook ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code in my Access application:

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)

Then later in the code, I use 'With OutMail' to send emails.

Is there a way within the VB code to specifiy the Outlook profile to use ?
(My app needs to run unattended and I can't have Outlook prompting
for the profile to use.)

Thanks,
Tom
 
Tom,
This is a .NET newsgroup, not Access nor VB6.

To answer your question, the Namespace.Logon method allows you to specify
the profile to use:

Something like (untested):

Dim OutApp As Outlook.Application
Dim OutNS As Outlook.NameSpace
Dim OutMail As Outlook.MailItem

Set OutApp = CreateObject("Outlook.Application")

Set OutNS = OutApp.GetNamespace("MAPI")
OutNS.Logon "My Profile"

Set OutMail = OutApp.CreateItem(olMailItem)

NameSpace.Logon has some optional parameters to specify password, UI, & new
Session...

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top