PDA

View Full Version : How to prevent Outlook from sending an email with a blank Subject line?


echarcha
March 27th, 2006, 11:31 AM
Hi,

Sometimes we forget to put the SUBJECT in the mails which we send. That could be deadly sometimes when you are communicating to the clients; to avoid such a situation, follow the steps below. There after when you send a mail without subject, a pop up window asks for your confirmation. You can try it !


Steps:
1.Open your outlook
2.Press Alt+F11. This opens the Visual Basic editor
3.On the Left Pane, one can see " Microsoft Outlook Objects", expand this. Now one can see the "ThisOutLookSession".
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$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
Cancel = True
End If
End If
End Sub

6.Save this and Now close the VB Code editor.
7.In Outlook Go to Tools > Macros > Security > In the Security Level Tab > Select the option MEDIUM > OK
8.Now Restart the Outlook, a dialog box pops up to Disable / Enable the macros; select as Enable Macros (this option will pops up when ever you restart outlook.
9.From now on , this macro will make sure you do not make the mistake of sending a mail without subject

That's it!

TerminatorJR
March 27th, 2006, 12:38 PM
vbMsgBoxSetForeground, "Check for Subject") = vbNoThen

7.In Outlook Go to Tools > Macros > Security > In the Security Level Tab > Select the option MEDIUM > OK


It works; :) only I had to separate vbNo and Then with a space.

When I looked at my Outlook's Tools --> Macros --> Security, it was high. Is it safe to keep it at the medium level ?

padhu
March 27th, 2006, 12:56 PM
I think you can do the same trick with Outlook Rules too rather than messing with VB Scripts.;) ;)

echarcha
March 27th, 2006, 01:09 PM
It works; :) only I had to separate vbNo and Then with a space.

When I looked at my Outlook's Tools --> Macros --> Security, it was high. Is it safe to keep it at the medium level ?

Updated with a space now..

Napolean
March 27th, 2006, 01:21 PM
I think you can do the same trick with Outlook Rules too rather than messing with VB Scripts.;) ;)
How do you do that?

padhu
March 27th, 2006, 02:01 PM
My mistake. I thought you wanted to block email addresses with blank subject line inside. Sorry. :eek: :eek:

echarcha
October 28th, 2008, 02:06 PM
I see a lot of folks landing on our technical How To pages.. Good to know :up:

dirtyfellow
February 22nd, 2011, 11:09 PM
Hi,

Sometimes we forget to put the SUBJECT in the mails which we send. That could be deadly sometimes when you are communicating to the clients; to avoid such a situation, follow the steps below. There after when you send a mail without subject, a pop up window asks for your confirmation. You can try it !


Steps:
1.Open your outlook
2.Press Alt+F11. This opens the Visual Basic editor
3.On the Left Pane, one can see " Microsoft Outlook Objects", expand this. Now one can see the "ThisOutLookSession".
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$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
Cancel = True
End If
End If
End Sub

6.Save this and Now close the VB Code editor.
7.In Outlook Go to Tools > Macros > Security > In the Security Level Tab > Select the option MEDIUM > OK
8.Now Restart the Outlook, a dialog box pops up to Disable / Enable the macros; select as Enable Macros (this option will pops up when ever you restart outlook.
9.From now on , this macro will make sure you do not make the mistake of sending a mail without subject

That's it!



Hi
It would be nice if u can provide the macro to prevent Outlook from sending an email without attachments ( mails which are intended for some attachments but sender usually forgets to attach the files ) :)

Ravi
February 24th, 2011, 07:05 AM
It would be nice if u can provide the macro to prevent Outlook from sending an email without attachments ( mails which are intended for some attachments but sender usually forgets to attach the files ) :)Not every mail has to have an attachment, and Outlook can't really read your mind to know you intended to attach a file.