1Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
2 If (Not Item.Class = olMail) Then Exit Sub
3
4 Dim mailItem As mailItem
5 Set mailItem = Item
6 If (mailItem.Subject = "") Then
7 answer = MsgBox("Do you want to send the message without entering a subject?",
8 vbYesNo + vbSystemModal)
9 If (answer = vbNo) Then
10 Cancel = True
11 End If
12 End If
13
14 msgBody = mailItem.Body
15 posAttach = InStr(1, msgBody, "attach", 1)
16 posFrom = InStr(1, msgBody, "From:", 1)
17 If (posAttach <> 0) Then
18 ' word "attached" found
19 wordInOldEmail = False
20 If (posFrom <> 0) Then
21
22 ' word "from: " found
23 If (posAttach > posFrom) Then
24 wordInOldEmail = True
25 End If
26 End If
27
28 If (Not wordInOldEmail And mailItem.Attachments.Count < 1) Then
29 answer = MsgBox("Do you really want to send the message without attachment?",
30 vbYesNo + vbSystemModal)
31 If (answer = vbNo) Then
32 Cancel = True
33 End If
34 End If
35 End If
36End Sub
37
As in the past, this is not a COM add-in. I have tested it with Outlook 2003 only in the VBScript Macro editor.
No comments:
Post a Comment