Hello, I'm new to VBA. I have a working macro below to send Outlook mail using Excel VBA:
I'd like to be able to send email using a 2nd account but I am having trouble getting the "Set .SendUsingAccount" to work. I'm using Office365. Any help would be greatly appreciated. Thanks in advance.
VBA Code:
Sub Use_2nd_Account()
Dim outlook As outlook.Application
Dim outlookmail As outlook.mailItem
Set outlook = New outlook.Application
Set outlookmail = outlook.CreateItem(olMailItem)
With outlookmail
.To = Sheet1.Cells(2, 1).Value
.CC = ""
.Subject = Sheet1.Cells(2, 2).Value
.Attachments.Add ActiveWorkbook.path & "/attachment1.png"
.HTMLBody = "hello world!"
'Set .SendUsingAccount = .Session.Accounts.Item(2)
.Display
End With
End Sub
I'd like to be able to send email using a 2nd account but I am having trouble getting the "Set .SendUsingAccount" to work. I'm using Office365. Any help would be greatly appreciated. Thanks in advance.