Hashim's Blogs

Thursday, February 10, 2005

How to prevent sending emails without subject in Outlook

1. Open your outlook
2. Press Alt+F11. This will open the Visual Basic editor
3. On the Left Pane, one can see "Project1", expand this, you can see “Microsoft
Office Outlook Objects”, expand this. Now one can see the “ThisOutLookSession”.
(If you are not seeing "Project1", press Ctrl+R or View-> Project
Explorer).
4. Click on “ThisOutLookSession”.
5. Copy and Paste the following code in the right pane.(Code Pane)
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(strSubject) = 0 Then
Prompt$ = "Subject is Empty !!!, Are you sure? you want to send the Mail?"
If MsgBox(Prompt$, vbOKCancel + vbQuestion + vbSystemModal +
vbMsgBoxSetForeground, "Check for Subject:-") = vbCancel Then
Cancel = True
End If
End If
End Sub
6. Now close the VB editor. From now on , this macro will make sure you do not make
the mistake of sending an email without subject

Note: You need to enable macros in the outlook for this code snippet to work.

How to prevent sending emails without subject in Outlook

1. Open your outlook
2. Press Alt+F11. This will open the Visual Basic editor
3. On the Left Pane, one can see "Project1", expand this, you can see “Microsoft Office Outlook Objects”, expand this. Now one can see the “ThisOutLookSession”. (If you are not seeing "Project1", press Ctrl+R or View-> Project Explorer).
4. Click on “ThisOutLookSession”.
5. Copy and Paste the following code in the right pane.(Code Pane)
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(strSubject) = 0 Then
Prompt$ = "Subject is Empty !!!, Are you sure? you want to send the Mail?"
If MsgBox(Prompt$, vbOKCancel + vbQuestion + vbSystemModal +
vbMsgBoxSetForeground, "Check for Subject:-") = vbCancel Then
Cancel = True
End If
End If
End Sub

6. Now close the VB editor. From now on , this macro will make sure you do not make the mistake of sending an email without subject
Note: You need to enable macros in the outlook for this code snippet to work.

How to prevent sending emails without subject in Outlook

1. Open your outlook2. Press Alt+F11. This will open the Visual Basic editor 3. On the Left Pane, one can see "Project1", expand this, you can see “Microsoft Office Outlook Objects”, expand this. Now one can see the “ThisOutLookSession”. (If you are not seeing "Project1", press Ctrl+R or View-> Project Explorer).4. Click on “ThisOutLookSession”.5. Copy and Paste the following code in the right pane.(Code Pane) Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim strSubject As String strSubject = Item.Subject If Len(strSubject) = 0 Then Prompt$ = "Subject is Empty !!!, Are you sure? you want to send the Mail?" If MsgBox(Prompt$, vbOKCancel + vbQuestion + vbSystemModal + vbMsgBoxSetForeground, "Check for Subject:-") = vbCancel Then Cancel = True End If End If End Sub 6. Now close the VB editor. From now on , this macro will make sure you do not make the mistake of sending an email without subject Note: You need to enable macros in the outlook for this code snippet to work.