Wednesday, May 03, 2006

Outlook 2003 - Warn if subject line is empty

This is my adaptation of the code found at: http://notepadexe.blogspot.com/2005/07/outlook-2003-warn-if-subject-line-is.html
  1. Go to the menu Tools → Macro → Visual Basic Editor.
  2. Now in the Visual Basic Editor, you should see Project1 in the tree menu on the left. Drill down the tree to Project1 → Microsoft Office Outlook → ThisOutlookSession.
  3. In the code area (the big text area on the right) paste in the following code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  If TypeName(Item) <> "MailItem" Then
    Exit Sub
  End If
  'CHECK FOR BLANK SUBJECT LINE
  If Item.Subject = "" Then
    Cancel = MsgBox("This message has no subject." & vbNewLine & _
                      "Do you wish to send anyway?", _
                      vbMsgBoxSetForeground + vbYesNo + vbExclamation, _
                      "No Subject") = vbNo
    If Cancel Then
      Dim myInspector As Outlook.Inspector
      Set myInspector = Item.GetInspector
      myInspector.Activate
    End If
  End If
End Sub

8 comments:

Laura said...

Hey Billy! wow all those codes and numbers... so scary!, but then again I am tech. challenged! ^_^
God bless~

Brice Helman said...

So if cancel is ture, then what does the sub routine do other than just send a message with "No Subject"?

You should have also included in this post that you can modify the string with your own personal message, sort of like a default subject line that you don't have to type in each time. I would also recommend modifying the subject line to be the name of the Sender so people know who it is without looking at the email address and trying to figure it out.

So can you modify other modules in outlook? I like coding but it is very difficult for me to start from scratch. I've been looking for decompilers to allow me to make Mods in the VB program. I just use the BASIC language.

Anonymous said...

Billy -

Thanks for the code. It worked perfectly. Is there a way to make this permanent? When I closed Oulook and reopen it, Outlook will send messages without the subject line.

Thanks,

Jack

Billy said...

Jack, it was permanent for me. The only thing I can suggest is that you make sure macros are enabled when you start Outlook. My Outlook always asks me if I want to enable macros when I start it up. I say "Yes" and it works for me.

Cheers!

Anonymous said...

Thanks Billy.
Subodh

Anonymous said...

Enabling macros in a safe mode.
http://www.pcreview.co.uk/forums/thread-854025.php

Dinesh Sehra said...

Thanks Billy. Works great.

Anonymous said...

Thanks a lot Billy for the code!!!

To JAck- May be u need to disable Macro from Macro security and save this Macro .It will be there for permanently.

Singh Piyush