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 Tools > Macro > Visual 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 Tools > Macro > Security.
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 Tools > Macro > Visual 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 Tools > Trust 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 IfEnd Sub
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.
Links to Other BlueDevilFan Articles
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?
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.
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?
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"
Comments (13)
Commented:
Commented:
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?
Author
Commented: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.
Commented:
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?
Author
Commented:Glad you like the article. Yes, that's possible. Replace line #4 of the original code with this line
Open in new window
View More