Outlook macro to stop sending an email without an attachment [VIDEO]

Automatic attachment check via VBA

I don’t do many Outlook macros, but this one is really useful and I have used it for a long time. It looks at your outgoing email and checks to see if you have the word attach in it and then checks to see if you have an attachment. It warns you if you don’t.

The macro is only seven lines and is listed below. It also checks for the string atach in case you typed it wrong.

Note: It will display the dialog if the string attach is in a previous email listed below the current email.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If InStr(1, LCase(Item.Body), "attach", vbTextCompare) + _
        InStr(1, LCase(Item.Body), "atach", vbTextCompare) > 0 Then
        If Item.Attachments.Count = 0 Then
          If MsgBox("No attachment, send anyway?", vbYesNo, "Attachment missing") _
            = vbNo Then Cancel = True
        End If
    End If
End Sub

You need to install the macro in your ThisOutlookSession module.

Copy the code above.

In Outlook press Alt + F11.

On the left of VBA screen that opens, double click the ThisOutlookSession module.

Paste the code in the empty space on the right of screen. Press Ctrl + S to save.

That’s it, ready to go.

Note: when you open Outlook you will need to enable macros.

The video below takes you through the steps and shows you how it works.

 

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.