A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Prevent Outlook from sending an email with a blank Subject Line



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 5th 09, 09:10 PM posted to microsoft.public.outlook.program_vba
Collector Dave
external usenet poster
 
Posts: 1
Default Prevent Outlook from sending an email with a blank Subject Line

How can I prevent Outlook 2007 from sending an email with a blank subject line?
Help Please!!
  #2  
Old November 6th 09, 03:55 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Prevent Outlook from sending an email with a blank Subject Line



See the ItemSend event, there you can check the item's Subject property, and
set Cancel=True if you don't want to send.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 5 Nov 2009 13:10:02 -0800 schrieb Collector Dave:

How can I prevent Outlook 2007 from sending an email with a blank subject

line?
Help Please!!

  #3  
Old November 6th 09, 08:29 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default Prevent Outlook from sending an email with a blank Subject Line

This event handler checks for blank subjects as well as if you try to
reply to a message with a blank subject.


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)

Dim Msg As Outlook.MailItem
Dim subj As String

If TypeName(Item) "MailItem" Then Exit Sub

Dim badSubjects() As Variant

badSubjects = Array(" ", "FW: ", " ")

Set Msg = Item
subj = Msg.Subject

If IsInArray(badSubjects, subj) Then
If MsgBox("Subject line is empty. Are you sure you want to send
this message?", _
vbQuestion + vbYesNo + vbMsgBoxSetForeground, "No
Subject") = vbNo Then
Cancel = True
End If
End If

End Sub

Function IsInArray(arr() As Variant, valueToCheck As Variant) As
Boolean
' returns true if value is found in array
IsInArray = (UBound(Filter(arr, valueToCheck)) -1)
End Function



On Nov 5, 4:10*pm, Collector Dave
wrote:
How can I prevent Outlook 2007 from sending an email with a blank subject line?
Help Please!!


  #4  
Old November 8th 09, 01:24 PM posted to microsoft.public.outlook.program_vba
Vivek
external usenet poster
 
Posts: 2
Default Prevent Outlook from sending an email with a blank Subject Line

Hi,

Open outlook, press Alt+F11 and press Ctrl+R. Navigate to
"ThisOutlookSession" and paste the below code, save (Ctrl+S) and close VB
editor. close and reopen outlook, enable macros.

Code-------
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
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

--
Thanks,
Vivek


"Collector Dave" wrote:

How can I prevent Outlook 2007 from sending an email with a blank subject line?
Help Please!!

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook blank subject line Paul[_17_] Outlook - General Queries 2 February 2nd 09 08:03 PM
Resend subject line is blank. Tish Outlook - Installation 4 March 6th 07 05:55 PM
outlook 2003 sending blank subject mail Mark Outlook - Installation 1 February 15th 06 07:54 PM
outlook 2003 sending blank subject mail Mark Outlook - Installation 0 February 15th 06 11:19 AM
Can Outlook warn if sending with a blank subject line ulkash Outlook - General Queries 4 February 7th 06 12:55 PM


All times are GMT +1. The time now is 12:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.