SHARE
TWEET

Outlook outgoing message attachment/categories reminder

a guest Oct 19th, 2010 1,006 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  3.     Dim m As Variant
  4.    
  5.     On Error GoTo handleError
  6.    
  7.     '' Attachment check starts
  8.    Dim strBody As String
  9.     Dim intIn As Long
  10.     Dim intMatch As Long
  11.     Dim intAttachCount As Integer, intStandardAttachCount As Integer
  12.     '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.
  13.    intStandardAttachCount = 0
  14.    
  15.     'Or, if you don't always use signature, define what files should not really count as an attachment
  16.    Dim arrIgnoreFiles(0)
  17.     arrIgnoreFiles(0) = "image001.gif"  ' Ignore image from my signature (your name might be different!)
  18.    
  19.     ' Now define the words that should trigger the "missing attachment" warning
  20.    Dim arrAttachWords(2)
  21.     arrAttachWords(0) = "attach"
  22.     arrAttachWords(1) = "viðheng"
  23.     arrAttachWords(2) = "meðfylgj"
  24.    
  25.     strBody = LCase(Item.Body)
  26.     intIn = InStr(1, strBody, "original message")
  27.     If intIn = 0 Then intIn = Len(strBody)
  28.     intMatch = 0
  29.     For Each srch In arrAttachWords
  30.         intMatch = InStr(1, Left(strBody, intIn), srch)
  31.         If intMatch > 0 Then
  32.             Exit For
  33.         End If
  34.     Next
  35.    
  36.     intAttachCount = Item.Attachments.Count
  37.    
  38.     For Each att In Item.Attachments
  39.         For Each fn In arrIgnoreFiles
  40.             If fn = att.FileName Then
  41.                 intAttachCount = intAttachCount - 1
  42.             End If
  43.         Next
  44.     Next
  45.    
  46.     If intMatch > 0 And intAttachCount <= intStandardAttachCount Then
  47.         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)
  48.         If m = vbNo Then Cancel = True
  49.     End If
  50.     '' Attachment check ends
  51.    
  52.     If Not Item.Categories <> "" Then
  53.         Call ShowCategoriesDialog
  54.         If Not Item.Categories <> "" Then
  55.             m = MsgBox("Would you like to send the message uncategorized?", vbQuestion + vbYesNo + vbMsgBoxSetForeground)
  56.             If m = vbNo Then Cancel = True
  57.         End If
  58.     End If
  59.    
  60. handleError:
  61.     If Err.Number <> 0 Then
  62.         MsgBox "Application_ItemSend: " & Err.Description, vbExclamation, "Outlook Attachment Reminder Error"
  63.     End If
  64.    
  65. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top