Macro to create email, and pick which email account to send from

Solved/Closed
TomTom111 Posts 4 Registration date Monday February 3, 2014 Status Member Last seen February 10, 2014 - Feb 3, 2014 at 07:02 PM
TomTom111 Posts 4 Registration date Monday February 3, 2014 Status Member 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
Related:

2 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Feb 4, 2014 at 10:32 AM
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:
https://www.rondebruin.nl/win/s1/outlook/account.htm

Good luck and best regards,
Trowad
3
TomTom111 Posts 4 Registration date Monday February 3, 2014 Status Member Last seen February 10, 2014
Feb 4, 2014 at 11:47 AM
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.
0