Community Pick: Many members of our community have endorsed this article.
Editor's Choice: This article has been selected by our editors as an exceptional contribution.

Avoiding Blank Subject Lines in Outlook

David Lee
CERTIFIED EXPERT
Published:
Updated:
Issue.  Have you ever received an email with a blank subject line?  Have you ever clicked "Send" only to realize that you forgot to add a subject?  It’s frustrating to receive a message with no subject.  You’ve no idea what the message is about, how important it is, whether it’s a legitimate message or spam, etc.  It’s even worse to send a message and forget to fill the subject in.  I’ve done it and I always feel foolish afterward.  I can’t help thinking what the recipients think.  This is especially true in a corporate environment where a message without a subject is downright unprofessional.

Background.  Unfortunately, Outlook does not enforce the use of the subject line or even offer an option for reminding you when you’ve forgotten to enter one.  From Outlook's perspective the subject is optional.

Solution.  Happily there’s a simple solution to this issue.  Through the use of a few lines of VBA (Visual Basic for Applications) code we can have Outlook check the subject line of every item we send.  If the subject line is blank, then the code can cancel the send and display a message asking us to give the item a subject.  Once the subject is filled in Outlook allows the item to go on its way.

Requirements.  This solution will work with any version of Outlook from 2000 through 2007.  Outlook 2010 adds a built-in check for a blank subject line (Note: Thanks to bromy2004 for pointing that out to me).  The solution does not work with Outlook Web Access (OWA).  OWA is Outlook in name only.  Unlike the full version of Outlook, OWA is a server-side process that runs at the Exchange server.  OWA does not support the use of VBA.

Instructions.  Follow these instructions to use this solution.

1. Add the Code to Outlook



Outlook 2000 - 2003.
1.      Start Outlook.
2.      Click ToolsMacroVisual Basic Editor.
3.      If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession.
4.      Copy the code below and paste it into the right-hand pane of Outlook's VB Editor window.
5.      Edit the code as needed.  I included comment lines wherever something needs to or can change.
6.      Click the diskette icon on the toolbar to save the changes.
7.      Close the VB Editor.
8.      Click ToolsMacroSecurity.
9.      Set the "Security Level" to Medium.
10.      Close Outlook
11.      Start Outlook
12.      Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Click Yes.

Outlook 2007.
1.      Start Outlook.
2.      Click ToolsMacroVisual Basic Editor.
3.      If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession.
4.      Copy the code below and paste it into the right-hand pane of Outlook's VB Editor window.
5.      Edit the code as needed.  I included comment lines wherever something needs to or can change.
6.      Click the diskette icon on the toolbar to save the changes.
7.      Close the VB Editor.
8.      Click ToolsTrust Center.
9.      Click Macro Security.
10.      Set "Macro Security" to Warnings for all macros.
11.      Click OK.
12.      Close Outlook
13.      Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Click Yes..

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
                          If Item.Subject = "" Then
                              'Edit the message and the popup caption on the next line as desired.'
                              msgbox "You are not allowed to send an item with a blank subject.  Please enter a subject and send again.", vbCritical + vbOKOnly, "Prevent Blank Subjects"
                              Cancel = True
                          End If
                      End Sub

Open in new window

2. Test the Solution


Create a test message and leave the subject blank.  Click Send.  Outlook should cancel the send and display a pop-up message that looks something like this.
Sample Blank Subject Warning Dialog-oxLinks to Other BlueDevilFan Articles

1. Creating Linked Notes in Outlook 2007
2. Extending Outlook Rules via Scripting
3. Importing and Exporting Outlook 2007 Categories
4. Outlook 2007 Corporate Categories System
5. Automatically Printing/Saving Emails/Attachments in Outlook
6. Never Again Forget to Add that Attachment to your Outlook Email
7. Enhancing Outlook 2007 Meeting Reminders
18
19,622 Views
David Lee
CERTIFIED EXPERT

Comments (13)

Mohammad Ishtyaq khatriSr. Systems Engineer
CERTIFIED EXPERT

Commented:
Thanks, Very useful.

Commented:
Boy I sure hope that you'll still see this since it was originally posted a year ago. My question is if there is a way to apply this macro to a remote computer w/out the user's knowledge? Perhaps with PowerShell?

I have a user that won't play nice and I would love to use this to force the issue but I assume that the user would need to be logged into so that it would be applied to his profile. Any suggestions?

CERTIFIED EXPERT
Top Expert 2010

Author

Commented:
Yes, that's possible but it does entail some risk.  There is no truly automated way of deploying Outlook macro code.   The closest you can come is to deploy Outlook's code file.  Outlook stores all macro code in a single file.  If you overwrite that file with a file of your own, say one containing this code, then the next time the user starts Outlook this code will take effect.  The risk here is that if the user has some Outlook code already, then when you overwrite their file they'll lose everything they had.  If you're fairly certain that the user in question doesn't have any Outlook macro code, then you can do this safely.

One other point to consider.  Outlook security has to be set to allow the code to run.  Depending on what version of Outlook the user has you may be able to do that via a GPO too.  If not, then the code will either be blocked by Outlook's built-in security or, worse, the user will be prompted to enable the code which will tip them off to what you've done.

The file you would need to copy is VbaProject.OTM.  It's found in slightly different locations depending on the version of Windows being used.
Great tip and works for me . . . to a point.

Now if the user tries to send with no subject they hear the Windows Warning beep and the message box pops up . . . but behind the open mail! The user has to click back on the Outlook icon in the taskbar to see the message box, click ok and can then go back to the email.

Is there anyway of bringing the msgbox to the front?
CERTIFIED EXPERT
Top Expert 2010

Author

Commented:
Hi, NELMO.

Glad you like the article.  Yes, that's possible.  Replace line #4 of the original code with this line

    MsgBox "You are not allowed to send an item with a blank subject.  Please enter a subject and send again.", vbCritical + vbOKOnly + vbApplicationModal, "Prevent Blank Subjects"

Open in new window

View More

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.