Skip to content
BusinessHut
Menu
  • Categories
    • News
    • Business
    • SaaS
    • Excel
    • Google Analytics
    • SEO
    • Cryptocurrencies
    • Microsoft
    • Google
    • Web Analytics
    • Excel Macros
    • how-to
Menu

Outlook Attachment Reminder Macro

Posted on August 27, 2010 by BusinessHut

How many times have you written an email about “the attached file” only to forget to attach the file before hitting send? If you follow the instructions in this post, that’ll never happen again!

We’re going to add a VBA macro to Microsoft Outlook that searches your email for the text “attach” when you click “send”. If it finds that string of text (ie. attached, attachment…) it will check to see if you actually attached a file. If there’s no file attached, you’ll be prompted with a message box. Then, you can either continue without attaching anything, or you can stop the email from sending so you can include your file. Yes, it’s that simple.

*Note: This will not work in Outlook Express as it doesn’t support macros.


How to set it up:

1. Open Outlook.
2. Press Alt+F11 : This will open the Visual Basic editor.
3. Expand the project until you find “ThisOutlookSession” and select it.
4. Copy the code below into the Visual Basic code window.
5. Save.

Now to test:
6. Close & Reopen Outlook for good measure.
7. Write an email containing the word attach.
8. Click send. *This is when you should get the pop-up.

*Note: If you have an image in your email signature, that would count as an attachment. Just change “intStandardAttachCount” from 0 to 1.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
‘ Pops up a reminder if the word “attach” is found but there is no attachment on your email.
Dim m As Variant
Dim strBody 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)

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 handleError: If Err.Number <> 0 Then
MsgBox “Outlook Attachment Reminder Error: ” & Err.Description, vbExclamation, “Outlook Attachment Reminder Error”
End If

End Sub

Also, LifeHacker has a script for GreaseMonkey that does the same thing for GMail.

Credit for this Outlook macro goes to Mark Bird. I’ve seen this macro a few times on the internets, but I believe he’s the original creator. You may also find some answers to any questions on his site. Thanks Mark!


There you go! Now anytime you mention an attachment in your email, you’ll be sure to have it attached.

26 thoughts on “Outlook Attachment Reminder Macro”

  1. Andrew says:
    November 8, 2010 at 12:43 pm

    HI Jason,

    I was wondering how you might modify the search criteria from just “attach” to include other possible key words (“list”, “file”, etc..)

    I’ve been using Mark’s orginal macro for some time and often wondered how this would work.

    Thanks!

    Reply
    1. Gerd says:
      August 8, 2013 at 7:24 am

      Dim keyword, word_found As String
      Option Base 1

      Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

      Dim bHasAttach As Boolean
      Dim Prompt As String

      ‘ sicherstellen, dass nur MailItems untersucht werden
      If Item.Class = olMail Then
      ‘ prüfen, ob möglicherweise ein Attachment erforderlich, aber nicht vorhanden ist
      If NeedsAttachment(Item.Body) Then
      bHasAttach = True
      If TypeName(Item.Attachments) = “Nothing” Then
      bHasAttach = False
      Else
      If Item.Attachments.Count = 0 Then
      bHasAttach = False
      End If
      End If
      If Not bHasAttach Then
      Prompt = “In der Mail >” & Item.Subject & “< fehlt möglicherweise ein Anhang (Schlüsselwort »" & word_found & "« gefunden). Trotzdem senden?"
      If MsgBox(Prompt, vbYesNo + vbQuestion, "fehlender Anhang") = vbNo Then
      Cancel = True
      End If
      keyword = "" 'kostbaren Speicher freigeben
      word_found = ""
      End If
      End If

      End If 'Item.Class = olMail

      End Sub

      Private Function NeedsAttachment(ByVal text As String) As Boolean

      Dim sPhrases As Variant
      Dim sPhrases_en As String
      Dim sTe As String
      Dim bNAtta As Boolean
      Dim i, iu, t As Integer

      ' Prüfstrings initialisieren

      sPhrases = Array("Anhänge", _
      "Anhang", _
      "Anlage", _
      "anhängend", _
      "Datei", _
      "beigefügt", _
      "anbei", _
      "attach") ', _
      "review")

      sTe = LCase(text)
      bNAtta = False
      iu = UBound(sPhrases)
      For i = 1 To iu
      t = InStr(1, sTe, sPhrases(i), 1)
      If t 0 Then
      keyword = sPhrases(i)
      bNAtta = True

      ‘Gesamtes Wort ausgeben, das den Schlüsselbegriff enthält
      word_found = keyword
      t = t + Len(keyword)

      While (IsLetter(Asc(Mid(sTe, t, 1))))

      word_found = word_found + Mid(sTe, t, 1)
      t = t + 1

      Wend

      Exit For
      End If
      Next

      NeedsAttachment = bNAtta
      End Function

      Function IsLetter(ByVal varWhat As Variant) As Boolean
      Dim i As Long, codes As Variant

      ‘ASCII-Codes für Groß- und Kleinbuchstaben lt. ASCII-Tabelle
      codes = Array(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, _
      97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122)

      IsLetter = True
      For i = LBound(codes) To UBound(codes)
      If (codes(i)) = (varWhat) Then Exit Function
      Next
      IsLetter = False
      End Function

      Reply
    2. Krishnamurthy says:
      June 14, 2016 at 1:11 pm

      Hi

      Can anyone help me out. I.need a macro code that should check all whether attached excel sent from outlook is password protected or not if no it should pop up a message.please help

      Reply
  2. Chiranjiv Kumar says:
    December 16, 2010 at 7:15 pm

    It doesn’t work in office outlook 2007.

    Reply
    1. Jason Green says:
      December 27, 2010 at 4:36 pm

      I’ll have to see if I can update the code for Office 2007 and 2010.

      Reply
      1. Melissa M. Miller says:
        July 26, 2011 at 12:14 pm

        Any word on the code for Outlook 2010.

        Reply
        1. Pascal N. says:
          December 14, 2011 at 6:14 am

          I had issues because of copy-paste :
          the quotation mark was modified from ” to “ which doesn’t work.
          Simply replace with ” and it works.
          Beware : the macro searchs for “original message” text.
          I replaced this with some text in my signature (which is automatically put in every email/answer).

          But I faced an error message when the attachement is already opened…
          I will look at it when I have more time…

          Reply
          1. Pascal N. says:
            December 14, 2011 at 6:15 am

            It seems that the website replaces the simple quotation mark by WORD-like quotation mark…

  3. Manuel says:
    March 15, 2011 at 3:03 pm

    Hi Jason,

    Is there a difference between files that you attach and files (images) attached in body message?

    I have to discard files attached in body message or to know when I attach a file that not belong to he message history.

    Thanks in advance.

    Best Regards.

    Manuel

    Reply
  4. Hannah Wood says:
    October 28, 2011 at 4:39 am

    I had this working but it simply stopped. Now I can send emails without attachments and I get no warning pop up. The script is still there in VBA but it seems to no longer have any effect. I ahve tried deleting it, repasting it, resaving it – I have closed and opened Outlook etc. Argh. It was SUCH a great little helper and now its gone 🙁

    Reply
    1. daem0n says:
      January 12, 2012 at 11:55 am

      Samehere, I wonder if an update broke it?
      I have the code in there and it was working, and get the same results as Hannah Wood.

      Reply
      1. John says:
        March 12, 2012 at 5:47 pm

        follow this websites step by step guide.

        danevans .co.uk/vba/

        Reply
  5. Anurag says:
    May 31, 2012 at 4:41 am

    I have already pasted some other macro (Subject empty reminder) in “ThisOutlookSession”. How do I out another macro for attachment reminder?

    Please advice.

    Reply
    1. Sundar says:
      June 5, 2012 at 8:33 am

      Just copy the content and paste it inside the method
      Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
      [****Here your code for subject empty reminder ***]
      [****here your code for attachment missing reminder ***]
      End Sub

      You should not create another method. Both the code should be in same method.

      It will work.

      Reply
  6. Shashwat Shriparv says:
    July 19, 2012 at 4:23 am

    Hi,

    Thanks for this code it help me alot. 🙂 cheers

    Reply
  7. Garrydene says:
    July 23, 2012 at 10:40 am

    Its very helpful only the words also appear in the disclaimer of some emails
    How do I exclude the words attach or enclose in the disclaimer of the email.

    Reply
    1. Jason Green says:
      July 23, 2012 at 10:59 am

      That would take some very specific analysis of the email text. It can be done, but you’d have to find and exclude the text in the signature/disclaimer.

      Reply
      1. Spoorthi says:
        September 5, 2012 at 6:44 am

        Hi Jason,

        I am actually looking for a macro that pops up an alert when we attach a file to the email in outlook 2010. It should pop up an alert message if there is any attachment in the email. Can you please help me with this..

        Reply
        1. Jason Green says:
          September 5, 2012 at 9:17 am

          @Spoorthi,

          I’ve been looking into something like this recently. We were thinking about automatically moving attachments to Sharepoint and instead providing links in the emails. I saw that you emailed me as well. I’ll follow up with more detail there.

          – Jason Green

          Reply
  8. Jayson G. says:
    September 12, 2012 at 3:11 am

    Mr. Jason,

    I am using microsoft 2010 also, i do really love your macro because it will help me a lot with my work but unfortunately its not working for 2010. Please also send me an update for this if possible.

    Thank You and Best Regards
    Jayson G.

    Reply
    1. Jason Green says:
      September 12, 2012 at 3:19 pm

      I’ll look into the changes needed to make this work with Outlook 2010. My workload is very full these days so I can’t promise how fast I’ll be able to check this out.

      Reply
  9. Manish says:
    September 27, 2012 at 12:29 am

    Hi Jason,

    I have a need to check if the files attached in the email are password protected (with or without winzip). The idea is to warn the sender if the files aren’t password protected. Can I get some help with this kind of macro ?

    Thanks,
    Manish

    Reply
  10. brittany says:
    October 24, 2012 at 2:14 pm

    I’m having a problem. If i reply to a message that the send says anything about an attachment the error message pops up. Is there a way for it to only look and the message body i’m sending and not other message details

    Reply
  11. Poiyo says:
    December 18, 2012 at 1:04 pm

    Hi Jason,

    I have implemented this macro in outlook and is working fine. But the same is promting me the message if the word “attach” is not present in the mail body. I mean to say I am getting reminder for al the emails . Please help on this..

    Reply
  12. Roger says:
    September 19, 2013 at 4:45 am

    Yeah I cannot get to work in Outlook 2010 either and have tried all tips – would have been great.
    Thanks for the effort, let us know if you are able to update it.
    Best regards
    Roger

    Reply
    1. Rebekah says:
      July 12, 2016 at 4:59 pm

      found the fix for this. You must allow Macros in the Trust Center on Outlook 2010.
      1.On the File tab, choose Outlook Options to open the Outlook Options dialog box, and then click Trust Center.
      2.Click Trust Center Settings, and then the Macro Settings option on the left.
      3.Select Notifications for all macros and then click OK. …
      4.Restart Outlook for the configuration change to take effect.

      Rebekah

      Reply

Leave a Reply Cancel reply

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

©2025 BusinessHut | Design: Newspaperly WordPress Theme