Avoiding Blank Subject Lines in Outlook

AID: 2959
  • Status: Published

11383 points

  • ByBlueDevilFan
  • TypeBest Practices
  • Posted on2010-04-24 at 10:08:01
Awards
  • Community Pick
  • Experts Exchange Approved
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 If
End Sub
                                    
1:
2:
3:
4:
5:
6:
7:

Select allOpen 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.

Blank-Subject-Warning.jpg
  • 15 KB
  • Sample Blank Subject Warning Dialog-ox
Sample Blank Subject Warning Dialog-ox



Links 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
    Asked On
    2010-04-24 at 10:08:01ID2959
    Tags

    outlook

    ,

    macro

    ,

    script

    ,

    blank

    ,

    subject

    Topic

    Outlook Groupware Software

    Views
    7381

    Comments

    Expert Comment

    by: younghv on 2010-04-24 at 13:49:12ID: 13749

    Very nice work here - and a great way to stop that too common "Oops" feeling.

    Thank you for putting this together - "Yes" vote above.

    Expert Comment

    by: goatbernard on 2010-04-24 at 15:39:11ID: 13752

    this is really nice, thanks your effort!

    Author Comment

    by: BlueDevilFan on 2010-04-24 at 15:45:44ID: 13755

    Thanks, guys.  Glad the tip was useful.

    Expert Comment

    by: bromy2004 on 2010-04-24 at 17:26:05ID: 13766

    Just an FYI,
    Outlook 2010 has this in by default.

    Expert Comment

    by: brettdj on 2010-04-25 at 04:51:52ID: 13788

    Thanks David :)

    Author Comment

    by: BlueDevilFan on 2010-04-25 at 06:46:28ID: 13794

    You're welcome, Dave!

    Expert Comment

    by: tigermatt on 2010-04-25 at 10:54:37ID: 13807

    Nice work BDF! Thanks.

    Author Comment

    by: BlueDevilFan on 2010-04-25 at 11:17:14ID: 13809

    Thanks, tigermatt!

    Expert Comment

    by: agentmik on 2010-05-09 at 02:46:02ID: 14173

    Thanks, Very useful.

    Expert Comment

    by: fmcsa001 on 2011-08-25 at 09:01:37ID: 30916

    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?

    Author Comment

    by: BlueDevilFan on 2011-08-25 at 10:10:50ID: 30918

    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.

    Expert Comment

    by: NELMO on 2012-04-11 at 05:08:36ID: 49461

    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?

    Author Comment

    by: BlueDevilFan on 2012-04-11 at 06:22:10ID: 49473

    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"
                                            
    1:
    

    Select allOpen in new window

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Join Experts Exchange Today

    Gain Access to all our Tech Resources

    Get personalized answers

    Ask unlimited questions

    Access Proven Solutions

    Search 3.2 million solutions

    Read In-Depth How-To Guides

    1000+ articles, demos, & tips

    Watch Step by Step Tutorials

    Learn direct from top tech pros

    And Much More!

    Your complete tech resource

    See Plans and Pricing

    30-day free trial. Register in 60 seconds.

    Loading Advertisement...

    Top Outlook Experts

    1. apache09

      663,644

      Sage

      2,168 points yesterday

      Profile
      Rank: Genius
    2. alanhardisty

      170,946

      Guru

      0 points yesterday

      Profile
      Rank: Genius
    3. demazter

      131,854

      Master

      0 points yesterday

      Profile
      Rank: Genius
    4. chris_bottomley

      109,375

      Master

      2,800 points yesterday

      Profile
      Rank: Genius
    5. thinkpads_user

      95,624

      Master

      750 points yesterday

      Profile
      Rank: Genius
    6. Rajkumar-MCITP

      89,780

      Master

      0 points yesterday

      Profile
      Rank: Guru
    7. l33tf0b

      83,091

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    8. BlueDevilFan

      73,191

      Master

      50 points yesterday

      Profile
      Rank: Savant
    9. jjmck

      66,336

      Master

      0 points yesterday

      Profile
      Rank: Genius
    10. Neilsr

      61,466

      Master

      0 points yesterday

      Profile
      Rank: Genius
    11. amitkulshrestha

      61,377

      Master

      0 points yesterday

      Profile
      Rank: Genius
    12. jcimarron

      49,232

      0 points yesterday

      Profile
      Rank: Genius
    13. ve3ofa

      46,002

      0 points yesterday

      Profile
      Rank: Genius
    14. dlmille

      45,200

      0 points yesterday

      Profile
      Rank: Genius
    15. akicute555

      44,979

      10 points yesterday

      Profile
      Rank: Wizard
    16. Anuroopsundd

      44,529

      0 points yesterday

      Profile
      Rank: Sage
    17. HendrikWiese

      40,896

      2,000 points yesterday

      Profile
      Rank: Sage
    18. Exchange_Geek

      37,449

      0 points yesterday

      Profile
      Rank: Sage
    19. jordannet

      36,757

      0 points yesterday

      Profile
      Rank: Wizard
    20. acbrown2010

      34,652

      0 points yesterday

      Profile
      Rank: Genius
    21. diverseit

      34,600

      0 points yesterday

      Profile
      Rank: Guru
    22. WORKS2011

      32,775

      0 points yesterday

      Profile
      Rank: Guru
    23. e_aravind

      31,941

      0 points yesterday

      Profile
      Rank: Genius
    24. JBlond

      31,700

      0 points yesterday

      Profile
      Rank: Sage
    25. limjianan

      30,910

      0 points yesterday

      Profile
      Rank: Genius

    Hall Of Fame