Prevent Outlook from sending an email with a blank Subject Line

Status
Not open for further replies.
C

Collector Dave

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

Help Please!!
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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

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!!
 
J

JP

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("RE: ", "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

<CollectorD...> wrote:
> How can I prevent Outlook 2007 from sending an email with a blank subjectline?
> Help Please!!
 
V

Vivek

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!!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
I How to prevent exchange email account from sending emails in Outlook Using Outlook 4
K How to prevent that Outlook is sending before my add-in is finished? Outlook VBA and Custom Forms 5
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
oj43085 Prevent Outlook from blocking image from a single source Using Outlook 4
D Prevent Outlook from resolving incomplete contact when clicking send Using Outlook 2
R How to prevent corrupted Notes format in Calendar and Contacts Using Outlook 0
O How to prevent image resize when pasting Using Outlook 2
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
O How to prevent CC from showing when creating a new mail? Using Outlook 1
A Prevent connection to Public Folders on Exchange? Exchange Server Administration 3
L OL 2016 contact: is there a way to prevent an admin from mistakenly deleting a contact? Using Outlook 1
D Multiple mailboxes, 1 certificate. How to prevent message "Invalid Certificate" Using Outlook 0
S How to prevent addins Using Outlook 0
makinmyway How Prevent Re-Formatting of Contact Notes Field When Syncing Using Outlook 10
Diane Poremsky Prevent Users From Choosing Stationery Using Outlook 0
evdbogaard How to prevent extra line feeds in replies Using Outlook 3
oliv- Prevent copying shared contacts Outlook VBA and Custom Forms 5
K Prevent meeting requests being sent from a shared calendar in a group mailbox Using Outlook 1
N Prevent reminder dismisal in shared calendar Using Outlook 1
C Security Question - How to prevent users exporting .iaf files Using Outlook 5
B Item_Write = False don't prevent custom form from closing Using Outlook 1
T WAB editing: To help prevent malicious code from running.......... Using Outlook 18
N Allow Another User to Send on Behalf of But Prevent Access to Inbox Using Outlook 4
R Exchange 2010 archive-prevent users moving items direct to archive Exchange Server Administration 1
M Links prevent sending email Using Outlook 3
K Prevent sending Excel files as attachements Outlook VBA and Custom Forms 1
G To Prevent Malicious Code from running, one or more objects in thi BCM (Business Contact Manager) 2
S To help prevent malicious code from running, one or more objects in this form were not loaded. For m Outlook VBA and Custom Forms 1
A Script to either modify "from" address or prevent a reply being se Outlook VBA and Custom Forms 2
J prevent user from installing wrong version of add-in Outlook VBA and Custom Forms 2
Z Prevent Changes to Custom Form Outlook VBA and Custom Forms 1
Retired Geek Outlook for the MAC with Yahoo accounts now very broken Using Outlook 6
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
L How Stop Outlook Nag Messages Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 1
L I Cannot Sign Into My Outlook Account? Outlook VBA and Custom Forms 0
icacream Outlook 2021 - Google calendar in the peek Using Outlook 0
e_a_g_l_e_p_i Question about installing my Gmail account on my iPhone but still getting messages downloaded to my desktop Outlook. Using Outlook 3
F Want to add second email to Outlook for business use Using Outlook 5
kburrows Outlook Email Body Text Disappears/Overlaps, Folders Switch Around when You Hover, Excel Opens Randomly and Runs in the Background - Profile Corrupt? Using Outlook 0
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
e_a_g_l_e_p_i MY Outlook 2021 changed the format of the shortcuts for mail, calendar etc. Using Outlook 10
Z Outlook 2021 Outlook new emails notification not working Using Outlook 5
K Changing the Deleted Items location in Outlook 2019 Using Outlook 2
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
V How to use Comas in a picklist in Outlook forms Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Question about reinstalling Outlook 2021 Using Outlook 5
A Outlook 365 Outlook (part of 365) now working offline - argh Using Outlook 5
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
G LinkedIn tab missing in Outlook 365 (but working in OWA) Using Outlook 0

Similar threads

Top