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

Reply using the address a message was sent to

Slipstick Systems

› Developer › Reply using the address a message was sent to

Last reviewed on May 24, 2018     29 Comments

Use this code to send a new message using the address the selected message was sent To as the send using From account.

See Using a Gmail Master Account: Reply using the Correct Account for instructions and an automated set of macros. It will work with any service that collects mail sent to other accounts.

This code is for people who use an account such as Gmail or Outlook.com to collect mail from other accounts and download only that account. Outlook will always reply using the account that downloaded the message, which is the Outlook.com or Gmail account. You'll need to create an account in Outlook for the other addresses to use this code, but can set the accounts to never download email.

This code gets the address the message was sent to and looks for an existing account with the same display name and uses that account. If it can't find a matching account it uses the account that downloaded the message. This could be changed to use the default account in your profile.

Update: I fixed the macro, it now checks for a specific string (an email address) in the To field. If it finds the address, the reply is from that address, otherwise the reply is from the default address. If you need to check for one of several accounts, you'll need to use an array.

To force the code to always use a specific non-default account, change this line:
objMsg.SendUsingAccount = olNS.Accounts.Item(1) to
objMsg.SendUsingAccount = olNS.Accounts.Item(2) where 2 is the placement of the account in the Account Settings list
or objMsg.SendUsingAccount = "Display name of desired account"

If you are using Exchange server and have Send as permission to the address a message was sent to (such as a distribution list), replace the For Each... Next block with:
objMsg.MailItem.Sender = oMail.To
or
objMsg.SentOnBehalfOfName = oMail.To

This may not work with Outlook 2013's "inline replies". Messages will be opened in a new Window.

Reply from the address a message was sent to

Public Sub AccountSelection()
Dim oAccount As Outlook.Account
Dim strAccount As String
Dim olNS As Outlook.NameSpace
Dim objMsg, oMail As MailItem
 
Set olNS = Application.GetNamespace("MAPI")
 
' For a reply all version, replace Reply with ReplyAll 
Set objMsg = ActiveExplorer.Selection.Item(1).Reply
 
If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
 Set oMail = ActiveExplorer.Selection.Item(1)
  
 On Error Resume Next
 
For Each Recipient In oMail.Recipients
 strRecip = Recipient.Address & ";" & strRecip
Next Recipient
 
 
If InStr(strRecip, "alias@domain1.com") = 1 Then
' StrAccount is the account name as shown in the Account Settings list
strAccount = "alias@domain1.com"
Else
End If
  
 For Each oAccount In Application.Session.Accounts
  If oAccount.DisplayName = strAccount Then
     objMsg.SendUsingAccount = oAccount
       Else
 
     ' to reply using the account that downloaded the message
     ' leave the objMsg line commented
     ' remove comment to reply using default account
     ' objMsg.SendUsingAccount = olNS.Accounts.Item(1)
 
  End If
Next
 
  objMsg.Display
 
Else
 
End If
 
Set objMsg = Nothing
Set olNS = Nothing
End Sub

Check for multiple aliases

This version of the macro, updated by Victor Beekman, checks for multiple aliases.

Public Sub AccountSelection()
Dim oAccount As Outlook.Account
Dim strAccount As String
Const strAlias1 = "alias1@somedomain.xxx"
Const strAlias2 = "alias2@somedomain.xxx"
Dim strRecip As String
Dim olNS As Outlook.NameSpace
Dim objMsg, oMail As MailItem
Dim Recips As Object
Dim i As Long

Set olNS = Application.GetNamespace("MAPI")
' to integrate with replyall button see https://www.slipstick.com/developer/remove-address-reply/
' For a reply all version, replace Reply with ReplyAll
Set objMsg = ActiveExplorer.Selection.Item(1).ReplyAll
 
 On Error Resume Next
 
Set Recips = objMsg.Recipients
For i = Recips.Count To 1 Step -1
  If LCase(Recips.Item(i).Address) = strAlias1 Then
     strAccount = strAlias1
     Recips.Remove i
  ElseIf LCase(Recips.Item(i).Address) = strAlias2 Then
     strAccount = strAlias2
     Recips.Remove i
  End If
Next i
  
 
If InStr(strRecip, strAlias1) = 1 Then
' StrAccount is the account name as shown in the Account Settings list
    strAccount = strAlias1
ElseIf InStr(strRecip, strAlias2) = 1 Then
    strAccount = strAlias2
End If
  
For Each oAccount In Application.Session.Accounts
  If oAccount.DisplayName = strAccount Then
     objMsg.SendUsingAccount = oAccount
       Else
      ' to reply using the account that downloaded the message
     ' leave the objMsg line commented
     ' remove comment to reply using default account
     ' objMsg.SendUsingAccount = olNS.Accounts.Item(1)
   End If
Next
objMsg.Display

Set objMsg = Nothing
Set olNS = Nothing
End Sub

How to use macros

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.
  3. Click Run to test the macro

When you're happy with the macro, create a ribbon or QAT button for the macro.

More information as well as screenshots are at How to use the VBA Editor

Reply using the address a message was sent to was last modified: May 24th, 2018 by Diane Poremsky

Related Posts:

  • Assign an Email Account to an Outlook Contact
  • Choose the account to send a reply from
  • Macros to send messages using a specific account
  • Foward a Message and CC the Original Recipients

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
29 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Estelle (@guest_218808)
October 14, 2021 10:10 am
#218808

Hi Diane, I have 2 outlook accounts including 1 imap account that is automatically transferred to my outlook.com account.
I would like that when I click on reply to an email sent to my imap account in my outlookaccount folder that the from field is "imap account" instead of exchange account and that I have a BCC field at a third address. I use in thisoutlook session a code that works for the BCC without worry. 
What can I do?
I also used a module but it requires me to click on the module instead of "reply to" which is not very convenient. Thanks in advance.

Translated with http://www.DeepL.com/Translator (free version)

Last edited 3 years ago by Estelle
0
0
Reply
Paolo (@guest_186377)
September 25, 2014 12:33 pm
#186377

Hi Diane, I try to use this macro to set the from field with the distribution group address as you suggest using Outlook 2013 on Windows 7 pro 32 bit, (the formsadmin doesn't work well with it), but the field remains the same.
Thanks for your time.

0
0
Reply
Diane Poremsky (@guest_186764)
Reply to  Paolo
October 2, 2014 12:23 pm
#186764

in exchange, you need to use the exchange alias or x500 address here:
If InStr(strRecip, "alias@domain1.com")

This will get the sender's address from a selected item. I prefer using /cn=alias part instead of just alias, but it can include a long string of number, at least with office 365 mailboxes.

Public Sub Getx500Address()
Dim objMail As Object
Set objMail = Application.ActiveExplorer.Selection.Item(1)
MsgBox objMail.SenderEmailAddress
Set objMail = Nothing
End Sub

0
0
Reply
Tim (@guest_185264)
August 17, 2014 7:44 pm
#185264

Hi
This Macro works well in specifying the correct account - thank you, however it does not pick up the Signature for that account in the reply text.
It still uses the default Signature.
Any thoughts on how to change the macro so it selects the correct Signature ?
Thanks

0
0
Reply
Diane Poremsky (@guest_185266)
Reply to  Tim
August 17, 2014 9:59 pm
#185266

You'll need to insert it using the macro - I don't have any code handy that does that though.

0
0
Reply
Fabio (@guest_183623)
May 24, 2014 5:48 am
#183623

Ok... Now you got me, what's an inspector?

0
0
Reply
Diane Poremsky (@guest_183628)
Reply to  Fabio
May 24, 2014 1:36 pm
#183628

it's how vba refers to an open item. A code example is here - https://www.slipstick.com/developer/vba-disable-outlook-2010-no-subject-warning/
this sample works with open or close: https://www.vboffice.net/en/developers/inspector-wrapper-receive-events-of-multiple-emails

0
0
Reply
Fabio (@guest_183618)
May 23, 2014 7:52 pm
#183618

Duh!...thanks Diane...I'd probably still be typing ".Category"...for those of you who want to know. I added the following to this macro. ' Set Category objMsg.Categories = "Sent By Fabio" objMsg.Save The reason I did it was due to the fact that my company is using Google Apps and because I'm using outlook in my office PC and my laptop, I have to use the "recent:" setting (recent:fabio@mydomain.com) on both machines, so I can make sure I get emails in both machines. Google mail seems to ignore the POP setting to leave messages on the server so it can be retrieved by another machine and IMAP doesn't work too well. The problem is that you get a duplicate of every email you sent into your inbox and when you're responding to lots of emails from clients (along with other co-workers using the same email aliases --- we really need a ticketing system but the boss thinks it's unnecessary). Anyway, I needed to identify the messages I sent versus the messages my co-workers sent, so I couldn't filter via the incoming email address otherwise I might miss one of their responses. So assigning a category only to the messages I sent allows… Read more »

0
0
Reply
Diane Poremsky (@guest_183619)
Reply to  Fabio
May 23, 2014 9:50 pm
#183619

you can but need to use an inspector. i'll see if i can find a code sample, im sure i have something here. Or you could use a macro instead of the New button...

0
0
Reply
Fabio (@guest_183589)
May 22, 2014 8:29 pm
#183589

To expand on this Macro, I wanted to include a specific Category every time I send from this Macro but I can't seem to do it. I thought it was simple as:

.Category = "Sent from Reply Macro"

Obviously the Category has already been created. I saw a few examples where a macro can display a list of categories to choose from but I can't seem to just set one without having to choose.

I'm not an expert on vb, so that might be the problem ;-)

-Fabio

0
0
Reply
Diane Poremsky (@guest_183590)
Reply to  Fabio
May 22, 2014 9:17 pm
#183590

it's .categories, not .category.

0
0
Reply
Michael (@guest_182529)
March 17, 2014 11:59 am
#182529

Diane, Found one more weird thing. If the email is sent to me ONLY (example To: a@b.com) the macro works.

However, if it is To: a@b.com; differentemail@c.com then it does not work. As in, if my email is only one of multiple addresses it does not work.

What would I need to modify to say if my email address is anywhere in the To: field then apply this rule?

0
0
Reply
Diane Poremsky (@guest_182547)
Reply to  Michael
March 17, 2014 11:44 pm
#182547

This: If InStr(strRecip, "alias@domain1.com") = 1 Then detects your address within the recipient string. Try > 0 instead of = 1

Is the case the same each time? If not, use the lcase function to force it to lower case - InStr(lcase(strRecip), "alias@domain1.com")

0
0
Reply
Michael (@guest_182523)
March 17, 2014 2:05 am
#182523

That fixed it!!! Thanks so much

0
0
Reply

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

Latest EMO: Vol. 30 Issue 16

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
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • How to Hide or Delete Outlook's Default Folders
  • Reset the New Outlook Profile
  • Save Attachments to the Hard Drive
  • Add Attachments and Set Email Fields During a Mail Merge
  • Outlook SecureTemp Files Folder
  • 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
  • Classic Outlook is NOT Going Away in 2026
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

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

Classic Outlook is NOT Going Away in 2026

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.

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