troubleshooting Question

Outlook No Subject Warning Stops Working

Avatar of martinzima
martinzimaFlag for United Kingdom of Great Britain and Northern Ireland asked on
Outlook
4 Comments1 Solution1179 ViewsLast Modified:
Hi,

I copied the below code into the "ThisOutlookSession" and it works fine until I reboot outlook. When I check the code after the reboot, Outlook has moved it into "Module1" and stops running the code (i.e. does not warn me before I send an email without a subject).

Can anyone please help.

Thanks,
Martin
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
Dim m As Variant
Dim strBody As String
Dim strSubject As String
Dim intIn As Long
Dim intAttachCount As Integer, intStandardAttachCount As Integer
 
On Error GoTo handleError
 
    'Edit the following line if you have a signature on your email that includes images or other files. Make    intStandardAttachCount equal the number of files in your signature.
    intStandardAttachCount = 0
 
    strBody = LCase(Item.Body)
    strSubject = Item.Subject
 
    intIn = InStr(1, strBody, "original message")
 
    If intIn = 0 Then intIn = Len(strBody)
 
    intIn = InStr(1, Left(strBody, intIn), "attach")
 
    intAttachCount = Item.Attachments.Count
 
    If intIn > 0 And intAttachCount <= intStandardAttachCount Then
        m = MsgBox("It appears that you mean to send an attachment," & vbCrLf & "but there is no attachment to this message." & vbCrLf & vbCrLf & "Do you still want to send?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
 
        If m = vbNo Then Cancel = True
    
    End If
 
    If Len(Trim(strSubject)) = 0 Then
            If MsgBox("Subject is Empty. Are you sure you want to send the Mail?", vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
                    Cancel = True
            End If
    End If
 
handleError:
 
    If Err.Number <> 0 Then
        MsgBox "Outlook Attachment Reminder Error: " & Err.Description, vbExclamation, "Outlook Attachment Reminder Error"
 
    End If
 
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros