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

Add Secure to the Message Subject before Sending

Slipstick Systems

› Developer › Code Samples › Add Secure to the Message Subject before Sending

Last reviewed on September 14, 2017     9 Comments

Several users asked me how to add secure to the message subject before sending the message.

I need a way to change the subject of an email after I hit send. Specific example: If I have a subject that says "meeting", after I hit send I would like the subject to be automatically changed to "meeting {Secure Message}"

Add Secure to the subject on Send
You can either use an ItemSend macro to add Secure automatically, or use macro to selectively add Secure to the message.

ItemSend

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim strSecure As String
 
strSecure = "Secure " & Item.Subject
Item.Subject = strSecure
     
End Sub

To use ItemSend and add Secure to the subject of some, but not all, messages, you need to use an If statement. If the message meets the condition, Secure is added to the subject.

In this example, we're testing for domains in the address. If a match is found, the subject is edited and sent. To send to all EXCEPT some domains, use
If InStr(LCase(strRecip), arrDomain(n)) = 0 Then.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim Recipients As Outlook.Recipients
Dim recip, strRecip As String
Dim i, n
Dim arrDomain As Variant
Dim strSecure As String

Set Recipients = Item.Recipients
  For i = Recipients.Count To 1 Step -1
    Set recip = Recipients.Item(i)
      strRecip = recip.Address & " " & strRecip
  Next i

' Set up the array
arrDomain = Array("domain1.com", "domain2.com")
 
' Go through the array and look for a match, then do something
For n = LBound(arrDomain) To UBound(arrDomain)
    If InStr(LCase(strRecip), arrDomain(n)) > 0 Then
        strSecure = "Secure " & Item.Subject
        Item.Subject = strSecure
        Exit Sub
  End If
Next n

End Sub

Macro Button on Ribbon

To use this macro, customize the message ribbon by adding a new button near the existing Send button.

Add Secure to Subject

Sub AddSecure()
Dim Item As MailItem
Set Item = Application.ActiveInspector.CurrentItem()
  
Dim strSecure As String
 
strSecure = "Secure " & Item.Subject
Item.Subject = strSecure
Item.Send
 
End Sub

Add Secure to Reply

Like the previous macro, you'll create a button on the ribbon for this macro. Click the button instead of Reply.

Public Sub SecureReply()
 Dim objApp As Outlook.Application
 Dim objItem As MailItem
 Dim strSecure As String

 Set objApp = Application
 Set objItem = objApp.ActiveExplorer.Selection.Item(1)
 Set Item = objItem.Reply
 
strSecure = "Secure " & Item.Subject
Item.Subject = strSecure
Item.Display
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 use the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

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

More Information

Message Security and Classification Tools
Secure E-mail Services

Add Secure to the Message Subject before Sending was last modified: September 14th, 2017 by Diane Poremsky
Post Views: 34

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Mastodon (Opens in new window) Mastodon
  • Email a link to a friend (Opens in new window) Email

Related Posts:

  • Automatically create a task when sending a message
  • Add a keyword to the subject of all messages sent
  • Foward a Message and CC the Original Recipients
  • Reply using the address a message was sent to

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.

Comments

  1. Krish says

    October 4, 2019 at 9:04 am

    Hello Diane,

    I have tested the above macro. I would like to confirm if its possible to prefix the subject line with the word "Secure"? Instead of changing the complete subject line?

    Because when i compose a new message in outlook 2013 and enter my own subject then after i click on the ribbon i created for secure message, its removes the existing subject line and overwrite with the word secure.

    Kindly assist.

    Thanks
    Krish

    Reply
  2. Tucker says

    July 18, 2019 at 12:46 pm

    Is there a way to do this but in the body of the email? So instead of adding 'passphrase' to the subject line when I click the button, I'd like to add it to the body of the email (ideally in white) and then immediately send the message. This is my current code:

    `Sub AddSecure()
    Dim Item As MailItem
    Set Item = Application.ActiveInspector.CurrentItem()

    Dim strSecure As String

    strSecure = Item.Subject & " [Passphrase]"
    Item.Subject = strSecure
    Item.Send

    ObjMail.Send

    End Sub'

    Reply
  3. Dennis says

    April 23, 2017 at 5:42 pm

    Hi Diane,

    I tried your code above however when doing the send using the code above always put secure in the subject line. How do I get it to only show the secure when sending to anyone else other than the domain I enter into the arrDomain?

    Reply
    • Diane Poremsky says

      April 23, 2017 at 10:28 pm

      To add it to all EXCEPT the domains listed in the array, use
      If InStr(LCase(strRecip), arrDomain(n)) = 0 Then

      Reply
  4. Dave says

    February 24, 2015 at 8:25 am

    Thank you. It works great!!

    Reply
  5. Dave says

    February 23, 2015 at 10:23 am

    That would be wonderful. Thank you, Diane.

    Reply
    • Diane Poremsky says

      February 23, 2015 at 6:58 pm

      It's the last macro on the page now.

      Reply
  6. Dave says

    February 20, 2015 at 4:21 pm

    Hi Diane,

    I came across this article and found it rather interesting and applicable to my situation. For me, the idea of having a button that added Secure to a subject line is perfect. I've created a quick step to create a message with Secure in the subject line but that doesn't work with replies. I like the Macro referenced above except for the fact that it immediately sends the email. It seems that it could be a good fit with a little tweaking. Basically, I'd like it to act like the Reply button. So, highlight the message, click the macro button. It adds Secure to the subject line and opens the message like Reply does. I suppose the ultimate solution would be something that would either create a New message with Secure in the subject or Reply to a message and add Secure to the subject line.

    Thanks,
    Dave

    Reply
    • Diane Poremsky says

      February 20, 2015 at 11:04 pm

      That won't be hard to do. I'm on a tablet tonight but will try to update the page with a new version tomorrow.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

Latest EMO: Vol. 31 Issue 8

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
  • Deleting Auto-Complete Entries No Longer Works
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • How to Hide or Delete Outlook's Default Folders
  • Disable "Always ask before opening" Dialog
  • Change Outlook's Programmatic Access Options
  • Adjusting Outlook's Zoom Setting in Email
  • Removing Suggested Accounts in New Outlook
  • Reset the New Outlook Profile
  • Understanding Outlook's Calendar patchwork colors
  • Deleting Auto-Complete Entries No Longer Works
  • Sync Issues and Errors with Gmail and Yahoo accounts
  • Error Opening iCloud Appointments in Classic 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
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

Deleting Auto-Complete Entries No Longer Works

Sync Issues and Errors with Gmail and Yahoo accounts

Error Opening iCloud Appointments in Classic 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

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 © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.