Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
- Dim m As Variant
- On Error GoTo handleError
- '' Attachment check starts
- Dim strBody As String
- Dim intIn As Long
- Dim intMatch As Long
- Dim intAttachCount As Integer, intStandardAttachCount As Integer
- '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
- 'Or, if you don't always use signature, define what files should not really count as an attachment
- Dim arrIgnoreFiles(0)
- arrIgnoreFiles(0) = "image001.gif" ' Ignore image from my signature (your name might be different!)
- ' Now define the words that should trigger the "missing attachment" warning
- Dim arrAttachWords(2)
- arrAttachWords(0) = "attach"
- arrAttachWords(1) = "viðheng"
- arrAttachWords(2) = "meðfylgj"
- strBody = LCase(Item.Body)
- intIn = InStr(1, strBody, "original message")
- If intIn = 0 Then intIn = Len(strBody)
- intMatch = 0
- For Each srch In arrAttachWords
- intMatch = InStr(1, Left(strBody, intIn), srch)
- If intMatch > 0 Then
- Exit For
- End If
- Next
- intAttachCount = Item.Attachments.Count
- For Each att In Item.Attachments
- For Each fn In arrIgnoreFiles
- If fn = att.FileName Then
- intAttachCount = intAttachCount - 1
- End If
- Next
- Next
- If intMatch > 0 And intAttachCount <= intStandardAttachCount Then
- m = MsgBox("It appears you wanted to send an attachment," & vbCrLf & "but didn't attach any file." & vbCrLf & vbCrLf & "Are you sure you want to send the message?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
- If m = vbNo Then Cancel = True
- End If
- '' Attachment check ends
- If Not Item.Categories <> "" Then
- Call ShowCategoriesDialog
- If Not Item.Categories <> "" Then
- m = MsgBox("Would you like to send the message uncategorized?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
- If m = vbNo Then Cancel = True
- End If
- End If
- handleError:
- If Err.Number <> 0 Then
- MsgBox "Application_ItemSend: " & Err.Description, vbExclamation, "Outlook Attachment Reminder Error"
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement