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

Report
Posts
4
Registration date
Monday February 3, 2014
Status
Member
Last seen
February 10, 2014
-
TomTom111
Posts
4
Registration date
Monday February 3, 2014
Status
Member
Last seen
February 10, 2014
-
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

2 replies

Posts
2591
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
February 11, 2020
396
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
3
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 4208 users have said thank you to us this month

Posts
4
Registration date
Monday February 3, 2014
Status
Member
Last seen
February 10, 2014

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.