• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Send email from another address using VBA

Slipstick Systems

› Developer › Code Samples › Send email from another address using VBA

Last reviewed on December 4, 2018     45 Comments

I need to send message from the certain E-mail address (E-mail Distribution Group) with VBA code. I have permission "Send as" and I can do it by hands, changing field "From".

Use SentOnBehalfOfName, and as long as your Exchange account has SendAs permission for the shared mailbox or distribution group, it will be sent from the shared account or group, not sent on behalf of.

Send as using VBA

If you want to send from another account in your Account list, you'll use SendUsingAccount and select the account by index or by name. See Macros to send message using the default account or a specific account for code samples.

SendAs an address code Sample

Note: this macro is used with Exchange account to send from addresses you have SendAs permissions.

Sub CustomMailMessage()
 
Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients
 
Set OutApp = CreateObject("Outlook.Application")
Set objOutlookMsg = OutApp.CreateItem(olMailItem)
 
Set Recipients = objOutlookMsg.Recipients
Set objOutlookRecip = Recipients.Add("alias@domain.com")
objOutlookRecip.Type = 1
  
objOutlookMsg.SentOnBehalfOfName = "sales@domain.com"
objOutlookMsg.Subject = "Testing this macro"
objOutlookMsg.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf

'Resolve each Recipient's name.
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next
 
'objOutlookMsg.Send
objOutlookMsg.Display
 
Set OutApp = Nothing
 
End Sub

More Information

Send E-mail with VBA code from [E-mail Distribution Group] if I have "Send as"
_MailItem.Sender property

Send email from another address using VBA was last modified: December 4th, 2018 by Diane Poremsky

Related Posts:

  • Exchange Server and Secondary Email Addresses
  • Send an Email to All Addresses on a Contact
  • Mail Merge to Contact Groups
  • Choose the account to send a reply from

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
45 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Michael MacMurray
September 25, 2023 8:50 am

Any idea how I can get emails sent using SentOnBehalfOfName to appear in the 'on behalf of' account's sent folder instead of my personal sent folder?

In other words, when I manually send an email and change the From field, the sent email appears in the Sent folder of the From account. However, when I send an email using VBA, the email appears in my Sent folder. Is there a way to change this?

0
0
Reply
Tomek
April 18, 2023 9:14 am

Hi,
I have two accounts in Outlook. My own account is called TWojcicki@MyDomain.com and the other which is my team account which is called MyTeam@MyDomain.com. I have a list of my team members in an XLSX file that I would like to send a message to.
I need to send different information to everyone on my list. I have prepared the file accordingly, each line contains a set of information needed to create an email.
The problem is that I would like to send these messages from the team account MyTeam@MyDomain.com and not from my personal TWojcicki@MyDomain.com. Meanwhile, following the instructions described by you, emails are still sent from my personal account TWojcicki@MyDomain.com.
I mean the line:
  OutlookMailitem.SendUsingAccount = OutlookApp.session.accounts.Item(2) ' Item(2) refers to my team account MyTeam@MyDomain.com
What could my mistake be?

0
0
Reply
Antoine
January 9, 2023 9:08 am

Is it possible to change the address of the person sending the email? Change antoine@mydomain.com to anonymous@mydomain.com?
Thanks for your answer.

0
0
Reply
Diane Poremsky
Author
Reply to  Antoine
January 10, 2023 8:12 am

You can type a from address in the new message field and you can change the address on the account in the Control panel -

Go to File > Account Settings > Manage Profile or open Control Panel - find Mail (Microsoft Outlook).
Click Email accounts then double click on the account - change the address at the top of the dialog - the address you use to log in is at the bottom.

0
0
Reply
Beyers
December 7, 2022 7:51 am

Hi,
How do I change Send As permissions so that I can send mail through VBA with an email address I do not currently have Send As permission?

0
0
Reply
Diane Poremsky
Author
Reply to  Beyers
December 7, 2022 9:54 pm

The email admin needs to change the permissions on the mailbox to give you send as permission in the Exchange admin portal.

0
0
Reply
Phillip
December 5, 2022 9:10 pm

and to add to my last comment because it wont let me, select a different email signature?

0
0
Reply
Phillip
December 5, 2022 9:08 pm

Hi Diane,

Is there a way to launch an oft template with the from address prefilled?

0
0
Reply
Diane Poremsky
Author
Reply to  Phillip
December 6, 2022 8:56 am

Yes... if you are using a macro to open the template, you can set the From address before displaying the template. There are macro solutions under this section:
https://www.slipstick.com/outlook/hyperlink-templates/#toolbar - they don't include the code to change the from account, but it needs to go before opening the template.
newItem.SentOnBehalfOfName = "sales@domain.com"
newItem.Display

0
0
Reply
Phillip
Reply to  Diane Poremsky
December 6, 2022 7:47 pm

so it would look something like this?

Sub MakeItem()
Set newItem = Application.CreateItemFromTemplate("c:\path\template.oft")
newItem.SentOnBehalfOfName = "sales@domain.com"
newItem.Display
Set newItem = Nothing
End Sub 

0
0
Reply
Diane Poremsky
Author
Reply to  Phillip
December 6, 2022 11:49 pm

Yes, try that. If it doesn't work, Try this line instead, where the number is the order the accounts are in the Account Settings list.

newItem.SendUsingAccount = olNS.Accounts.Item(1)

0
0
Reply
Mark Pollock
September 26, 2022 12:02 am

Hi ive currently made a login register which works well. when someone adds in their details to the userform and submits a new login request or change it sends an email notification to the person currently in control. this currently sends from my default outlook work email. (MarkP@Example.com.au) i need this to be changed to send from a different email thats in my outlook as my main one is getting spammed with requests and theres now 3 registers. how can i add in a FROM field? so it sends from LoginRegisters@Example.com.au instead of my main email my code below Private Sub cmdEdit_Click()    Dim xOutApp    As Object    Dim xOutMail   As Object    Dim msgvalue   As VbMsgBoxResult    On Error GoTo myerror    msgvalue = MsgBox("Do you want To save the data?", vbYesNo + vbInformation, "confirmation")    If msgvalue = vbNo Then Exit Sub    If ValidateEmptyEntries() = True Then        Call Edit        Call reset    Else        Err.Raise 600, , "duplicate validation failed or empty field must be filled"    End If     cmdEdit.Enabled = False     cmdSubmit.Enabled = True     txtUser.Enabled = True    'email notification    Set xOutApp = CreateObject("Outlook.Application")    Set xOutMail = xOutApp.CreateItem(0)    With xOutMail        .To = "MarkP@example.com.au"        .CC = ""        .BCC = ""        .Subject = "WMS LOGIN REGISTER"        .Body = "Account Update Requested By… Read more »

0
0
Reply
Diane Poremsky
Author
Reply to  Mark Pollock
December 7, 2022 10:07 pm

This should work -
With xOutMail
.SentOnBehalfOfName = "sales@domain.com"
.To = "MarkP@example.com.au"
.CC = ""

1
0
Reply
Mervyn
July 8, 2022 10:27 pm

Can this be tweaked to change the address when responding or forwarding if the address is in the To or CC fields? e.g. if the email was addressed to user@email.com then the From address when responding would automatically change to user@email.com (with SendAs permission).

0
0
Reply
Diane Poremsky
Author
Reply to  Mervyn
July 9, 2022 12:08 am

Yes, it can be tweaked.
https://forums.slipstick.com/threads/99391-change-from-address-based-on-to-or-cc-address/

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 32

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment