August 29, 2011

Alert if subject is blank in outlook

Sometimes in hurry we forget to write subject in outlook.
To avoid this we need to do following stuffs.

Step 1:
Press Alt+F11 it will VBA editor as below.

Step 2: Now Click on “thisoutlooksession” in left pane and then write below code in VBA editor.

   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 blank. Are you sure you want to send the mail?"
    If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Please check your subject") = vbNo Then
    Cancel = True
    End If
    End If
    End Sub

Now whenever we will send email without subject it will show alert.
But it will function for current session only means if we will restart 
outlook it will not function.
In order to make it permanent we need to do following things.

Go Tools ==> Macros ==> Security

Click on Security …



Make security level medium.Now it will work permanently.
But whenever you will start your outlook you will get below message.



Of course you have to click on Enable Macros.

Now If we are sending email without subject we will get below alert.



That’s It
Enjoy Learning.

No comments:

Post a Comment