hope you can help me out.
I have a VBA script in Excel that, among many other things, sends an email via Outlook 365. Now, my primary email account (@outlook.com) has five aliases. These are not separate email accounts but merely aliases associated with that primary account (which itself is one out of a half a dozen primary accounts). See attached picture for maybe a better explanation I'd like to set one of those aliases as the From address but it's just not happening.
This is the relevant snippet; everything else in the Sub, including creating the email and setting the attributes and attachments, works great.
Dim emailAlias As String
emailAlias = "f...@outlook.com"
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Subject
.To = Cells(cellRow, 2).Value
.SentOnBehalfOfName = emailAlias 'doesn't work
.SendUsingAccount = emailAlias 'no go either
.HTMLBody = msg
.Attachments.Add fileName
.Display
End With
What am I doing wrong?
BTW, setting the alias as the default account can only be done online at live.com so that's not an option as it would be too cumbersome to have to (re)set it several times a day, plus it takes Outlook 365 forever to recognize the switch.
So, is thee a way to specify an alias of a primary account as the From email address?