A1VBCode Forums

Sending a Mail merge from Mutilpe Email Accounts


http://www.a1vbcode.com/vbforums/Topic26086.aspx

By KaosTheory - 10/27/2008

Hey All

I have a dilema. I currently have Outlook 2003 which has mutiple mailboxes. I have created a Macro in Word 2003 that sends out emails after i run a mail merge. Problem is I have multiple mailboxes and each mail merge needs to be sent from a different email account depending on a field in the mail merge.

Anyone have any idea how I how to send an email from a certain address.

EG: Merge field 'a' needs to be sent from email adress a@a.com and if merge field has 'b' in it then it needs to be sent from b@b.com

How do I get it to to send from these mailboxes as if it was from these fields and not "on behalf of"

Thanks

KaosTheory

By Ashutosh - 1/5/2009

Dim oAccount As Outlook.Account

dim SentFrom As String



if whatever you are checking is true then

SentFrom = emailaddress1

else

SentFrom = emailaddress2

end if



' Selected Email Account must be a valid Email Account on the PC you are sending the Emails from.



For Each oAccount In Application.Session.Accounts

If oAccount.SmtpAddress = SentFrom Then

mailMail.SendUsingAccount = oAccount

Exit For

End If

Next

If mailMail.SendUsingAccount Is Nothing Then

msgbox("Account Not Found")

end if