Outlook email blank subject warning

oostendeEver now and so often, it happens that I forget filling in the mail subject when composing an email in Outlook (typically when I have to send a rather important email…).

Save yourself the annoyance by following the next steps.

  1. Open the Visual Basic Editor (in Outlook, press ALT+F11).
  2. On the left-hand side of the screen, expand the ‘Project1’ (go into ‘Microsoft Office Outlook Objects’ -> ‘ThisOutlookSession’).
  3. Double click on ‘ThisOutlookSession’
  4. Paste the following lines of code in the right-hand pane of the screen:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

 If Item.Subject = "" Then
 Cancel = MsgBox("This message does not have a subject." & vbNewLine & "Do you wish to continue sending anyway?", vbYesNo + vbExclamation, "No Subject") = vbNo
 End If

End Sub

Save the project (‘File’ -> ‘Save’) and return to Outlook. From now on, the code will be called every time you press the send-button after you composed an email. Outlook will pop up a warning when you try sending an email with an empty subject line.

The code has been tested on Outlook 2003 and 2007.

Credits: this code is extracted from a more sophisticated script .

Extra info: if you want to go ‘all the way’, you can also self-sign your macro so that Outlook does not present you with a warning every time you start the program up.

16 thoughts on “Outlook email blank subject warning”

  1. HI!

    Your code does’n work. I have 2007 edition.

    You forgot to extract some other lines from the sophisticated script – if you click NO (don’t send message) he send it.

    So here is the working code:

    ————————————————–

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

    If Item.Subject = “” Then
    bCancelSend = MsgBox(“This message does not have a subject.” & vbNewLine & _
    “Do you wish to continue sending anyway?”, _
    vbYesNo + vbExclamation, “No Subject”) = vbNo
    End If

    Cancel = bCancelSend

    End Sub

    ——————————–

    CHEERS!!

    Palito (Slovakia)

  2. Hey Palito,

    I don’t see a difference between your code and mine.

    Can you explain the difference?

    Kind regards,
    Lieven.

  3. Hi Lieven,

    at first I would like to thank you for your code.

    Actualy I didn’t look at the differences between your and my code, because the flash wasn’t working at that time. And also I thougth that Cancel = bCancelSend is missing but I was wrong. It was late night.

    So now I was reinstalling my PC and I again needed this code, so I came here again. I tried your code and only one thing is there wrong:

      -> on line six

    😀

    Regards,

    Palito

  4. I can write here HTML code, so it’s not showing the error..

    Here it ist (read without spaces):

    & n b s p;

    Palito

  5. Hey Palito,

    indeed, that was a leftover from a copy/paste from the HTML of my previous site.

    Fixed!

    Regards,
    Lieven.

  6. If you add vbDefaultButton2 to the second parameter, you can set the default to No, which I prefer, since I almost always want a subject:

    Cancel = MsgBox(“This message does not have a subject.” & vbNewLine & “Do you wish to continue sending anyway?”, vbYesNo + vbExclamation + vbDefaultButton2, “No Subject”) = vbNo

  7. I just used this for Outlook 2007 after sending two emails to colleagues without subjects and it works great, easy too. Just wanted to show my gratitude!

  8. Guys,

    Don’t know what it is but it isn’t working for me on Outlook 2007. Any ideas??

Comments are closed.