Question : Outlook No Subject Warning Stops Working

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
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
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

Answer : Outlook No Subject Warning Stops Working

Hi, martinzima.

I have NEVER seen Outlook move code from one module (e.g. ThisOutlookSession) to another (e.g. Module1).  The only two things I can think if are a damaged Outlook code file (i.e. the file VbaProject.OTM which is stored in the folder C:\Documents and Settings\\Application Data\Microsoft\Outlook) or a damaged Outlook profile.  For the former, copy all Outlook macro code to a file, then close Outlook and delete the code file.  When you start Outlook again it will create a new code file.  Copy your code back into Outlook, save it, then try again.  For the latter, use the Mail applet in the control panel to create a new Outlook profile.
Random Solutions  
 
programming4us programming4us