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

Select from a List of Subjects before Sending a Message

Slipstick Systems

› Developer › Select from a List of Subjects before Sending a Message

Last reviewed on August 14, 2016     36 Comments

OutlookForum member X82 needs to change the subject of replies.

Instead of the subject reading "RE: Info", I must change it to a pre-set sentence like Authorization 0054213. The number will change but the first part is always the same. Is there a way of making outlook change the subject line?

A quick but "dirty" method is to use an InputBox to select a number, which then inserts the correct subject. (The code for this is at Change subject)

It's also possible to do this using a ComboxBox, but its more complicated and requires a UserForm.

Before using the macro, you need to set Outlook's macro security to Low or to warn. Then open the VBA editor using Alt+F11. More information on using the VBA editor is at How to use the VBA Editor

For a variation of the code that contains a proper Cancel command, see cancel-subjects.txt. Follow the instructions below, but add a second command button to the Userform and change the caption to Cancel.

Step 1: Create the Userform.

  1. Right click on Project1 and select Insert > UserForm
  2. Open the control Toolbox and select a ComboBox and add it to the UserForm.
  3. Add a Command button.
  4. Right click on the Command button and choose Properties.
  5. Type OK (or Change Subject) in the Caption field.
  6. Right click on the UserForm and choose View Code.
  7. Paste the code below into the code window.
  8. Change the subject titles as desired. This list is for your reference only, not the actual text that will be added to the subject. The subject text is changed in the VBA macro code.

Private Sub UserForm_Initialize()
  With ComboBox1
    .AddItem "Subject 1"
    .AddItem "Subject 2"
    .AddItem "Subject 3"
    .AddItem "Subject 4"
    .AddItem "Subject 5"
    .AddItem "no change"
End With
End Sub

Private Sub CommandButton1_Click()
    lstNo = ComboBox1.ListIndex
    Unload Me
End Sub

Create a userform and add controls to it

Step 2: Add VBA macro for reply

Next you need to add the macro that creates the reply then asks you to select the new subject.

  1. Right click on Project1 and choose Insert > Module.
  2. Paste the code below into the Module.
  3. Change the subject lines to use the desired text. If you want to include the original subject, use oMail.Subject = "Subject " & objMail.Subject format.

To test, select a mail item and run the macro. The macro works with a selected or open message, thanks to the use of the GetCurrentItem function.

Public lstNo As Long

Public Sub ChangeSubjectOnReply()

Dim objItem As Object
Dim oMail As Outlook.MailItem

Set objItem = GetCurrentItem()
Set oMail = Application.ActiveExplorer.Selection(1).Reply

 oMail.Display
   
   UserForm1.Show

  '  MsgBox "user chose " & lstNo & " from combo"

    Select Case lstNo
    Case -1
         oMail.Subject = objItem.Subject
    Case 0
         oMail.Subject = "Subject 1"
    Case 1
        oMail.Subject = "Subject 2"
    Case 2
       oMail.Subject = "Subject 3"
    Case 3
       oMail.Subject = "Subject 4"
    Case 4
       oMail.Subject = "Subject 5"
    End Select
End Sub

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
          
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
      
    Set objApp = Nothing
End Function

Video Tutorial

Import a ready to use form

Because this is more complicated than just pasting a macro, I have ready to use code available for download. Import it into the VBA editor and it's ready to run. ChangeSubject VBA

 

More Information

The second part of X82's question was how to get a code from the message body and add it to the subject. To do this you need to find the code in the body. You can do this by parsing the body and looking for a string. Basic instructions are at Parse text fields using VBA. For best results, it needs to be in the body in the same location, eg, as "Authorization: 123456789". Once you find the code and assign it to a string value, enter it into the subject using this format:
oMail.Subject = "Authorization " & strCode

VBA UserForm sample: Select from a list of templates

Select from a List of Subjects before Sending a Message was last modified: August 14th, 2016 by Diane Poremsky

Related Posts:

  • VBA UserForm sample: Select from a list of templates
  • Outlook VBA: Use a Text File to Populate a ListBox
  • Selectively change message format when replying
  • This macro copies a meeting request to an appointment. Why would you w
    Copy meeting details to an Outlook appointment

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

Gabriela
February 8, 2022 11:41 am

Hi Diane,
This script is similar with what I would need and It would be great if you could help me out to adapt it to my need.
I will have an open email that I intend to forward (manually click send) to a certain email address, always the same one, but the subject line differs for each email. I want to enter a certain number in the combo box, and a certain subject to be auto-populated. Could you please help me with codding for this one?
Would be much appreciated!
Thank you!

0
0
Reply
Sameer
December 12, 2019 10:33 pm

How to use dynamic subject list?

0
0
Reply
Aaron Bolton
October 1, 2018 8:15 pm

Hi, I have used this code to setup a macro to add subject from a drop down. As per the example it works by selecting a contract and running the macro which works fine, however I would like to also be able to select a contact group to populate the To. It does not work when I do try to do this, is there a way I can make it work for a contract group?

Thanks

0
0
Reply
Jake
August 18, 2018 5:19 pm

Hi Diane,

If I will place the value I have from the combobox on the email body, how am I going to format it (font size, font style, bold)?

Thank you

0
0
Reply
Athena Passos
June 29, 2017 7:18 pm

Diane,

I'm trying to use the combobox to allow user to select between a list of carriers,
like "Carrier 1", "Carrier 2" and "Carrier 3", and based in the selection, the macro
populates the "To" field in the email with the respective emails for the carrier.
Is that possible?

0
-1
Reply
Diane Poremsky
Author
Reply to  Athena Passos
June 29, 2017 8:28 pm

Sure. In the combo box, you put the carrier names and in the Select case, you'd use oMail.To = "alias@address".

0
0
Reply
Jerald Nicholas
October 9, 2016 3:16 am

Dear Diane,

Thanks a lot for the effort.
This is the one I am looking for a long time.
I would like to add some more things for my project. Please tell me how to set up hotkey(ALT+T) to run a macro in OUTLOOK 2013.

Looking forward for your reply

Thanks
Jerald Nicholas

0
0
Reply
Ashwin Mathew
August 14, 2016 8:03 pm

Hi Diane,

Thanks for this tutorial, I have this working with some minor modifications. I wanted to ask, is there any way to launch the macro when creating a new email in outlook? Instead of going through the developer tab ever time, I'd like to macro to run and prompt me for the subject line whenever I create a new email. Will be great if you can advise on this.

Thank you,
Ash

0
0
Reply
Diane Poremsky
Author
Reply to  Ashwin Mathew
August 14, 2016 9:42 pm

As long as the macro is one you run (not an automatic macro that runs when something happens) you can create a button on the ribbon for it. See https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/#button if you aren't sure how to do it.

0
0
Reply
Ashwin Mathew
August 14, 2016 1:00 pm

Hi Diane,

Thanks for this tutorial, I got this working pretty well with some modifications. I wanted to ask, is there any way to trigger this macro anytime a new email is created in outlook. Meaning I'd want the form where I select the subject lines to appear when I click "New Mail Message", instead of going through the developer tab ever time.

Thanks,
Ash

0
0
Reply
Diane Poremsky
Author
Reply to  Ashwin Mathew
August 14, 2016 4:33 pm

You need to use the newinspector - see https://www.slipstick.com/developer/code-samples/default-subject-messages/ for an example. I think (did not test) you'd add UserForm1.Show and select case lines to the newinspector macro.

0
0
Reply
Diane Poremsky
Author
Reply to  Ashwin Mathew
August 14, 2016 4:53 pm

This is working here -
Declare this in a new module (if you have other modules already in use, put it at the top of one)
Public lstNo As Long

Use the macros at the page i linked to and replace the inspector active macro with this
Private Sub m_Inspector_Activate()
Dim strSubject as String
Select Case lstNo
Case -1
strSubject = objItem.Subject
Case 0
strSubject = "Subject 1"
Case 1
strSubject = "Subject 2"
Case 2
strSubject = "Subject 3"
Case 3
strSubject = "Subject 4"
Case 4
strSubject = "Subject 5"
End Select

If TypeName(m_Inspector.currentItem) = "MailItem" And _
m_Inspector.currentItem.Subject = "" Then
m_Inspector.currentItem.Subject = strSubject
End If
Set m_Inspector = Nothing
End Sub

0
0
Reply

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

Latest EMO: Vol. 30 Issue 36

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
  • Mail Templates in Outlook for Windows (and Web)
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • Adjusting Outlook's Zoom Setting in Email
  • Disable "Always ask before opening" Dialog
  • Remove a password from an Outlook *.pst File
  • This operation has been cancelled due to restrictions
  • Syncing Outlook with an Android smartphone
  • Removing Suggested Accounts in New Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • 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
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

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

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

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