Contents of question

I want to automatically reply to emails with an address other than the one used mainly in VBA installed in Outlook.
At that time, the phrase "(main address) is sent on your behalf" is inevitably included in the reply email.
If anyone has any information on how to get rid of this wording, would you please tell me?

Corresponding source code

With objMail
.SentOnBehalfOfName = ""
.To = "mail address"
.Subject = "email subject"
.Body = "email body"
.BodyFormat = olFormatPlain'Mail format
.Send'Send Email
End With


-The version of Microsoft Office will be 2019.
-The sender address I want to change is the address added to Outlook.
-It was not displayed when the sender was changed manually.
・ The mail server is "Name.com"

  • Answer # 1

    I solved it by adding the syntax to switch the account itself as follows.

    Dim objOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem
    Dim ObjAccount As Object

    Set objOutlook = New Outlook.Application
    Set objMail = objOutlook.CreateItem (olMailItem)
    Set ObjAccount = objOutlook.Session.Accounts.Item ("mail account")'From account setting

    ~~ Labor saving ~~

    .SendUsingAccount = ObjAccount'Switch sender account