Select Outlook Profile to Send E-mail

BrianB75

Registered User.
Local time
Today, 10:00
Joined
Aug 27, 2004
Messages
43
I am currently working on a database that will be sending out multiple reports but they need to be sent from different e-mail profiles. I have the two profiles set up but I am at a loss with how to select which profile to use in my code.

Here is a sample:

Code:
Dim obEmail As Object, obMsg As Object, obAttachment As Object, stDelim As String, exAttach As String

stDelim = ";"
Set obEmail = CreateObject("Outlook.Application")
Set obMsg = obEmail.CreateItem(olMailItem)

With obMsg
    .subject = "Ordering Report"
    .To = "users"
    .Body = "Please see attached."
    .Send
    
End With

Set obEmail = Nothing
Set obMsg = Nothing

End Function

I thought about using the 'SentOnBehalfOfName' property but from what I've seen this does not change the e-mail address. This is key since the recipients will probably reply back and these replies need to be routed to the correct profile.
 
Hey Brian,

Hopefully someone with more Outlook VBA skills than I have chimes in.

I've been looking for the same thing for my application. Best I've been able to come up with is a forward/move rule set in Outlook depending on the subject line.

it's a bit clunky but solves the issue for me. Anyone else?

Chris
 
Just as a follow-up I ended up using the GetNameSpace function:

Code:
Set obEmail = CreateObject("Outlook.Application")
Set mynamespace = obEmail.GetNamespace("MAPI")
Set obMsg = obEmail.CreateItem(olMailItem)
mynamespace.Logon "ProfileName", , , True

Had our IT department set up a new e-mail account, added the profile to the PC I'm using and then added the above code. Worked on both Access 2002 and Access 2007.
 

Users who are viewing this thread

Back
Top Bottom