Don't miss the latest updates, ever

[How-To] Write Macro For Blank Subject Warning In Microsoft Outlook

Tuesday, 19 May 2009, 8:57 | How-To | 7 Comments | Read 1153 Times
by Vaibhav Pandey

Has it ever happened to you that you wrote an interesting, meaningful, content rich email but forgot to put a subject before you pressed the Send Button. Earlier, i wrote about writing a Macro for not missing attachments (Read[How-To] Missed Outlook Attachment,get warned before its too late

In this article, we will write a Macro for validating Blank Subject in Microsoft Outlook client. Follow the steps below in order to create such a macro

1.) Ensure that Macros are enabled for your Microsoft Office Outlook. Macros don’t work with Microsoft Outlook Express, therefore this setup cannot be achieved with Microsoft Outlook Express.

2.) Ensure that your security level is set to Medium. You can set the security level by clicking on Tools –> Macro –> Security. Set the desired level to Medium.

3.) Traverse through Tools –> Macro –> Visual Basic Editor ( Or press ALT + F11)

4.) Expand Project 1 by clicking on the + sign.

5.) Expand Microsoft Office Outlook Objects.

6.) Double click ThisOutlookSession.

7.) Copy paste the following code. 

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
   Dim strSubject As String
   strSubject = Item.Subject
   If Len(Trim(strSubject)) = 0 Then
       Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
      If MsgBox(Prompt$, vbYesNo + vbQuestion + _
	vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
        Cancel = True
      End If
  End If
End Sub
Image: Macro for validating empty subject line in Microsoft Outlook.

Image: Macro for validating empty subject line in Microsoft Outlook.

8.) Once the code is pasted, click on Save and then Exit. The above code ensures that when you send an email, the subject line is not blank. If, the length of the subject line is zero, the macro alerts you with a popup.

Am sure, once you have created this macro, you will be able to avoid sending blank subject emails. 

Via

Also ReadRecovering ‘permanently’ deleted email in Microsoft Outlook 2003

Recovering Hard Deleted Items in Outlook 2003.

 

You can follow me on Twitter at http://twitter.com/vaibhav1981

Do stay tuned to Technofriends for more, one of the best ways of doing so is by subscribing to our feeds. You can subscribe to Technofriends feed by clicking here.



Follow me on Twitter at @vaibhav1981
Tagged with: , , , , , , , , , , , , , ,
  • Jayesh

    Thanks for this tip, but it works only for one session when Outlook is open. If you close and start outlook, it doesnt work.

  • Vish

    The code works fine as long as you are in the same session when the script has been saved. Though it is still saved in the macros, it doesn’t work upon restart of outlook. This is in Outlook 2007.

  • Vish
  • Miriam

    Thank you!!!!!
    very very helpful and clear!

  • Sangeetha

    Hi Vaibhav,

    Thanks for two very usefl macros for Outlook:
    To get warning if subject line in blank; and
    To get warning if the mail body contains the words “attach, attached, attachment” etc and no attachment found with in the e-mail

    These are very useful.

    But I am facing one problem. I am not able to apply both of the macros togheter for the same outlook session.

    That is, i am either able to apply only the syubject line macro or the attachment macro.

    What should or how should i go about to have both macros in the Visual Editor on my Outlook 2007 session.

    Am not technical Savy. So can you please provide a step by step procedure to do so (like you have done for hot to apply each of various macros…)

    Thanks again.

    Look forward to your reply.

    Regards,

    Sangeetha

  • Ashish sharma

    Hi It’s worked very nice thanks I will be always thankful to you

  • Pingback: Outlook: how can a non-empty subject be forced in an E-mail message?