Macro to create email, and pick which email account to send from [Solved/Closed]

Posts
4
Registration date
Monday February 3, 2014
Last seen
February 10, 2014
- Feb 3, 2014 at 07:02 PM - Latest reply:
Posts
4
Registration date
Monday February 3, 2014
Last seen
February 10, 2014
- Feb 4, 2014 at 11:47 AM
I already have this set up how I want...

Sub MakeMsg()
Dim msg As Outlook.MailItem
Today = Format(Now(), "mm-dd-yy")
Set msg = Application.CreateItem(olMailItem)
With msg
.To = "XXXX@XXX.com"
.Subject = Today & " Subject Line"
.Display
End With
End Sub


What I can't figure out is how to pick which email to send from.
I have several emails in my outlook, but when the Macro is run, it defaults to the wrong email.

How can I go about changing this?

--Thanks
See more 

2 replies

Best answer
Posts
2448
Registration date
Sunday September 12, 2010
Status
Contributor
Last seen
November 20, 2018
Feb 4, 2014 at 10:32 AM
3
Thank you
Hi TomTom111,

Since I don't use outlook, it's hard to test.

But take a look at this site. It seems to me it has the answer you are looking for:
http://www.rondebruin.nl/win/s1/outlook/account.htm

Good luck and best regards,
Trowad

Thank you, TrowaD 3

Something to say? Add comment

CCM has helped 1695 users this month

Posts
4
Registration date
Monday February 3, 2014
Last seen
February 10, 2014
Feb 4, 2014 at 11:47 AM
0
Thank you
That is exactly what I need, thank you!

This is the line I am using to specify which email account to use...

CreateObject("Outlook.Application").Session.Accounts.Item(1)

By changing the number in Item(x), I was able to get the correct email account "number" in outlook, thereby creating a new message from the correct account every time.

Props to TrowaD for the find.