I am trying to create an auto-mailer for Outlook with Excel VBA.
I created mailers in the past and the .SentOnBehalfOfName function worked.
On those mailers and the new mailer, it no longer works.
I have access to the email address.
I can send emails from that email address, and have in the past.
I can create the email using the mailer and it appears as it should, so the mailer functions are working.
The emails do not display the required email address, but instead my personal work email address.
Now I manually change the email From field.
Sub Make_Email(Wood As Variant, metal As Variant, SendID As Variant)
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
Dim i As Integer
Dim NewSubject As Variant
Dim InvoiceCount As Integer
Dim PartnerName As Variant
Dim Folder As Variant
Dim EmailLR As Variant
Dim EmailArray As Variant
Dim mainWB As Workbook
Dim CCID
Dim Subject
Dim Body
Dim olMail As MailItem
Set otlApp = CreateObject("Outlook.Application")
Set olMail = otlApp.CreateItem(olMailItem)
Set Doc = olMail.GetInspector.WordEditor
Dim Link As Variant
Dim EmailBody As Variant
EmailBody = "text of email is here"
Subject = "Subject text is here"
With olMail
.SentOnBehalfOfName = "[email protected]" 'this is the part that is not working
.To = SendID
.Subject = Subject
.HTMLBody = EmailBody
.Display
'.Send
End With
End Sub
I've researched but nothing seems to indicate the .SentOnBehalfOfName function has changed or has been removed from use.
I checked the references with my new mailer versus my old mailer and they are all turned on.
- Office 16.0 object library
- Outlook 16.0 object library
- outlook sharepoint social provider
- outlook social provider extensibility
- outlook view control
I've even turned on
- winhttp services version 5.1
- microsoft xml v3.0
I tried a Mr. Excel forum solution to move .SentOnBehalfOfName below the .To option.
Using VBA to send Outlook Email / Sent on Behalf Of Name
I tried a StackOverflow solution to place the .SentOnBehalfOfName as the first statement and then the .Display.
SentOnBehalfOf not working in Excel 2010 VBA Code