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

Macro to Warn Before Sending a Message with a Blank Subject

Slipstick Systems

› Outlook › Email › Macro to Warn Before Sending a Message with a Blank Subject

Last reviewed on May 23, 2017     35 Comments

Applies to: Outlook 2007

Outlook 2010 and newer will check messages for a blank subject automatically, a macro is not needed.
Blank subject warning
Surprisingly, some users hate this but there is no way to disable it in Outlook Options. If want to disable this warning, you can disable the warning using a macro.

Anyone using Outlook 2007 or older who wants a warning when the subject line is blank needs to use a macro.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 Dim strSubject As String
  strSubject = Item.Subject
     If Len(Trim(strSubject)) = 0 Then
         Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
       If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
        Cancel = True
      End If
    End If
End Sub

How to use this macro

Using a macro in Outlook, short version:

  1. Step 1: Enable macros in Tools, Macro Security or Tools, Trust Center (Outlook 2007). We recommend the 'warn for all macros' setting (Medium in Outlook 2003 and older). With this enabled, you'll need to allow macros each time you start Outlook. In older versions of Outlook, you may need to close and restart Outlook before the macros will work.
    Allow macros to run

  2. Step 2: Open the VBA Editor using Alt+F11 keystroke.
  3. Step 3: Expand the Project menu and select ThisOutlookSession
  4. Step 4: Copy and paste the macro into ThisOutlookSession. The text should be blue, green and black. Red text means there is a syntax error in that line.
  5. Step 5: Save (Ctrl+S or Save button). Note: you'll need to save the VBA project when you close Outlook too.

Test the macro by sending a message with a blank subject.

Blank subject warning

If it works as expected, you can use SelfCert to sign the macro then set Outlook's macro security to signed macros only. Instructions for using SelfCert are available at How to use Outlook’s VBA Editor

Warn before doing other stuff...

You can use this to warn about things beside a blank subject. Depending on what you are checking, you will need to either remove or edit the first two lines:

Dim strSubject As String
strSubject = Item.Subject

Then change the IF statement to test the field you want to test:
If Len(Trim(strSubject)) = 0 Then

For example, to check the TO address, we need to change those lines to this:
'Item = MailItem
If Item.To = "alias@domain.com" Then

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

   'Item = MailItem
     If Item.To = "alias@domain.com" Then
         Prompt$ = "Are you sure you want to send this message?"
       If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check before Sending") = vbNo Then
        Cancel = True
      End If
    End If
End Sub

More code samples are available at

Warn Before Sending Messages to the Wrong Email Address

More Information

More Code Samples:
E-Mail: Check item size before sending

Macro to Warn Before Sending a Message with a Blank Subject was last modified: May 23rd, 2017 by Diane Poremsky
Post Views: 75

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:

  • Check for missing attachments before sending a message
  • Do You Want to Send This Message Without a Subject?
  • Warn Before Sending: Checking Contact Categories
  • Disable Outlook's No Subject Warning using VBA

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. Dennis Parteka says

    May 21, 2017 at 11:28 am

    I see this code all over the internet and everyone says how wonderful
    it works but it doesn't work for me, I'm clueless, any ideas why? I'm not
    getting an error, it just seems to not run the macro. Windows 7 Office 2010.

    Reply
    • Diane Poremsky says

      May 23, 2017 at 12:35 am

      it definitely won't show in the macro list (first screen shot) - it's an auto macro and will run when you send a message. You don't need to do anything to make it run (but click Send).

      Do you have macro security set to low? That is the usualy cause...

      (I'll try to record a video showing how to do it and it in action tomorrow. )

      Reply
      • Dennis Parteka says

        May 23, 2017 at 7:09 am

        Thank you for responding and for your help, I really appreciate it.
        Yes, security is as low as possible. I’ve tried running this on
        Windows-7 Office 2010 and Windows-10 Office 2016 and also tried
        changing the fourth line… it’s driving me a little nutty.
        From… If Len(Trim(strSubject)) = 0 Then
        To… If Len(Trim(strSubject)) = "No" Then

      • Diane Poremsky says

        May 23, 2017 at 8:52 am

        Now wait a minute - why do you need this with either outlook 2010 or 2016? It has the warning built in - you should get this dialog box. If you also use the macro, it will come up after this one.

      • Diane Poremsky says

        May 23, 2017 at 1:07 pm

        oh, i see the problem - len is length.
        Use this instead
        If InStr(1, strSubject, "Phrase") > 0 Then

        If there is any chance any letter in the string could be a different case, use lowercase for everything:
        If InStr(1, lcase(strSubject), "phrase") > 0 Then

  2. Tai says

    August 4, 2016 at 6:19 pm

    I created a request form with fields for users to enter in Outlook. However, I would like all the fields to be entered prior to the form getting sent. How can I prompt a message box stating "Please enter all the fields" when the user is trying to send the form with one or more blank fields?

    Reply
  3. Navdeep says

    June 24, 2016 at 6:17 am

    1.Is there is way to add any prompt on recieving any mail in Outlook.For exaple.
    Do you want to archieve this mail.
    2.On Yes, I want to use our own Product calls to archieve emails in repository.
    3. Once Archieved , Flag of mail should be marked stating that mail has been archieved in repository.?

    Reply
    • Diane Poremsky says

      June 25, 2016 at 12:21 am

      Do you want the prompt as the mail arrives? if so, an itemadd macro can do the prompt and the flag. Whether it can use your archiving software depends on the software.

      Reply
  4. Ken says

    November 2, 2015 at 2:13 pm

    I use a template in outlook 2007 where I need to edit the subject every time before I send it. In the template, the subject is "Ticket #". What is the code to get a prompt before sending out a message with a specific subject? I want it to warn me if I forget to edit the subject of the template. So If the subject = "Ticket #" then prompt me if I want to send out the email.

    Reply
    • Diane Poremsky says

      November 4, 2015 at 8:45 am

      use this - first 8 characters = ticket # to prompt for all messages that begin with ticket #. if you wanted to warn only if there was not something after ticket #, use the second one, 10 would allow for 2 digit or larger ticket #. That can be increased.
      If Left(strSubject, 8) = "Ticket #" Then
      If Left(strSubject, 8) = "Ticket #" and Len(Trim(strSubject)) < 10 Then

      Reply
  5. Don says

    October 6, 2015 at 7:04 pm

    I would like to applaud you for following up on comments from an almost three yr old post!

    I am trying to modify a subject to apply some leading text (to encrypt via our servers) to emails sent to any address besides two specific ones. I modified the code based off something I found online a while ago to just add the encrypt text to everything, but it gets kind of messy with some people's filters. Below is the code, any thoughts how to fix it? Thank you in advance!

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

    If (Right(Trim(Item.To), 15)) "@exampleone.com" Then
    Item.Subject = Item.Subject
    ElseIf (Right(Trim(Item.To), 15)) "@exampletwo" Then
    Item.Subject = Item.Subject
    Else
    If (Left(Trim(Item.Subject), 8)) "SECURE: " Then
    Item.Subject = "SECURE: " + Item.Subject
    End If
    End If
    End Sub

    Reply
    • Diane Poremsky says

      October 6, 2015 at 9:50 pm

      The macro at https://www.slipstick.com/developer/code-samples/add-secure-message-subject-sending/ uses a cleaner method if you need to exclude multiple domains and also check all of the recipient addresses.

      Not sure the purpose of this - if the subject has secure, it doesn't need it added. Oh, i bet wordpress ate the 'does not equal brackets' <>
      If (Left(Trim(Item.Subject), 8)) "SECURE: " Then
      Item.Subject = "SECURE: " + Item.Subject

      These could be combined into an OR... but the else works too. just exit sub and send if the statement is true.
      If (Right(Trim(Item.To), 15)) "@exampleone.com" Then
      exit sub
      ElseIf (Right(Trim(Item.To), 15)) "@exampletwo" Then
      exit sub

      Else
      If (Left(Trim(Item.Subject), 8)) <> "SECURE: " Then
      Item.Subject = "SECURE: " + Item.Subject

      Reply
    • Don says

      October 7, 2015 at 6:03 pm

      That was prefect. Thank you!

      Reply
    • Don says

      October 7, 2015 at 6:08 pm

      Is there a way to add if the address is an Exchange address, as those do not show domains? Thank you!

      Reply
      • Diane Poremsky says

        October 10, 2015 at 12:15 am

        So you want it to trigger for any internal email address? Try looking for /ou in the address or "" (nothing). if that fails, you couls look up the pr_smpt_address - 'Check for different domains' macro at https://www.slipstick.com/how-to-outlook/prevent-sending-messages-to-wrong-email-address/ shows how.

  6. Deepa says

    July 2, 2015 at 11:31 am

    can you help me with the code for warning message "Please read the email or check the attachment before sending"

    Reply
    • Diane Poremsky says

      July 2, 2015 at 1:18 pm

      if you want to check all mail, remove the If and End if lines. Change the text within the prompt string.

      Reply
  7. Mark says

    June 1, 2015 at 2:55 pm

    Diane,

    If I just want a macro to stop any and every email before I send it so I can check it one more time, what would I do? I'm not checking for a specific field. Rather, I simply want a "speed bump" with text in the pop up that makes me reconsider sending it or allows me to cancel if I'm not sure.

    I've done this before, looking at your site (I think) but I've forgotten now that I switched to a new computer.

    Reply
    • Diane Poremsky says

      July 2, 2015 at 1:22 pm

      If you remove the IF and end if lines, it'll check all messages.

      Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
      Prompt$ = "Are you sure you want to send this message?"

      If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check before Sending") = vbNo Then
      Cancel = True
      End If

      End Sub

      Reply
  8. rohitrajsbl says

    December 8, 2014 at 12:10 pm

    Hi Everyone,
    I want to create a Macro in outlook 2013. If I am attaching anything in email then a popup box should appear with the statement “You are attaching a file. Please check if XYZ field available in the file” Presse YES or NO. Also in the popup box should be one check box If I checked the button then a note should be include with the email.

    Please help me to solved this out.

    Reply
    • Diane Poremsky says

      January 7, 2015 at 1:33 am

      That one is complicated and I don't have any macro samples that do that. Sorry.

      Reply
  9. dpons039 says

    November 20, 2014 at 4:58 am

    Hello, I really love this warnings and I'm using them regularly.

    I need to have one to check if the subject has an specific word "test"

    If Subject has "test" -> Send email
    If Subject does not have "test" -> Warn if you want to send it.

    Thank you Diane!

    Reply
    • Diane Poremsky says

      November 20, 2014 at 9:25 am

      You'd add another if:
      If Len(Trim(strSubject)) = 0 OR If instr(lcase(strSubject, "test")) = 0 Then

      by using lcase, it works with any case: Test, test, TEST, tEsT etc.

      Reply
      • dpons039 says

        November 20, 2014 at 11:39 am

        Hello Diane,

        That doesn't seem to work, i'm geting a:
        compile error - Expected: Expression.
        I'm at Outlook 2007

      • Diane Poremsky says

        November 20, 2014 at 8:44 pm

        User error :-) This is the correct format for the line:
        If Len(Trim(strSubject)) = 0 Or InStr(LCase(strSubject), "test") = 0 Then

        That should teach me not to copy and edit a line instead of just typing it in from scratch. :)

  10. Shashank says

    November 5, 2014 at 11:07 pm

    The one for subject did'nt work for me....gave me a expected end of statement error...
    This worked for me though (Outlook 2007)

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

    If Item.Subject = "" Then

    MsgBox "You forgot the subject."

    Cancel = True

    End If

    End Sub

    Reply
    • Diane Poremsky says

      November 6, 2014 at 11:49 pm

      The only issue is that adding a space to the subject field will bypass the check. This will strip leading/ending spaces from the subject and trigger the message if the subject only contains spaces.
      If Len(Trim(strSubject)) = 0 Then

      Reply
  11. Miles says

    July 22, 2014 at 12:15 am

    I would love to Add company Logo to this message ? I have change to are you sure you are sending this to the correct recipient ? - I feel the company logo will make it look more professional , can this be done ??

    Reply
    • Diane Poremsky says

      July 22, 2014 at 1:04 am

      You can't use a logo with the msgbox - you could if you created a userform, but that takes away from the simplicity of code.

      Reply
  12. Prakash says

    March 10, 2014 at 5:13 am

    I want to give Warning message ,before sending mails containing following keyword "enjoy", "Fun" , "Party" , Please be careful ,don't send this type of mails.

    Only Warning, before sending. Please guide

    Reply
    • Diane Poremsky says

      March 10, 2014 at 9:20 am

      You'd use this format: instr(1,"keyword") > 0 but because you want to use multiple keywords, you'd use an array or case statement.

      select case instr(1,strKeyword)
      keyword "enjoy", "Fun" , "Party"
      ' code to do is there is a match
      end select

      Reply
  13. Candice says

    January 14, 2013 at 5:13 pm

    This works perfectly for me, but instead of warning when I send to a particular e-mail address, I need it to warn me before I send to one of the company's distribution lists. I can't get the macro to recognize addresses that are stored in our company's Global Address book.

    Reply
    • Diane Poremsky says

      January 14, 2013 at 7:04 pm

      Using the display name works here:
      If Item.To = "Submissions" Then

      Because DLs are expanded on the server, if you need to check for a member of a DL, you'd need to expand the DL using code then look for an address using InStr function. Also, the macro is case-sensitive - you can use lcase to make it insensitive.

      Reply
  14. jon says

    May 22, 2012 at 12:05 pm

    Can this be modified to popup a message whenever I email a particular address? I just want to have that extra reminder to remove financial information from our board meeting minutes before I send them to a particular person.

    Thanks,
    Jon

    Reply
    • Diane Poremsky says

      May 22, 2012 at 12:24 pm

      Yes, it can. Remove the Dim line, change the subject and if line to the following -

      Item = MailItem
      If Item.To = "diane@here.com" Then

      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 10

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
  • Removing Suggested Accounts in New Outlook
  • Disable "Always ask before opening" Dialog
  • Change Outlook's Programmatic Access Options
  • Reset the New Outlook Profile
  • Adjusting Outlook's Zoom Setting in Email
  • 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.