Outlook Attachment Reminder Or, How to Get Outlook To Remind You to Insert a Forgotten Attachment

Many times folks forget to attach a file and send the mail and suddenly you realize you missed an attachment and then, you fire a second email says something like, “Oops! Here’s the attachment” Isn’t that embarrasing?


So, here you will find couple of articles explaining outlook VBA programming in a simple way;


First off, how to add VB code to outlook? Check out the easy steps as explained By KC Lemson [MS]


How to add VBA macro code to Outlook and run it once;


http://blogs.technet.com/kclemson/articles/87356.aspx


 


So, now we know How to add VBA macro code to Outlook and run it once. Ok, let’s add the code which is available from “You forgot to attach the file!” for ease, allow me to paste the code here;







Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim lngres As Long
    If InStr(1, Item.Body, “attach”) <> 0 Then
        If Item.Attachments.Count = 0 Then
            lngres = MsgBox(“‘Attach’ in body, but no attachment – send anyway?”, _
                            vbYesNo + vbDefaultButton2 + vbQuestion, “You asked me to warn you…”)
            If lngres = vbNo Then Cancel = True
        End If
    End If
End Sub





kclemson says, “This works best if Outlook is your editor. If Word is your editor, the dialog will pop up behind Word, I believe this is a limitation that cannot be worked around when using VBA.


Ricardo Silva [Outlook MVP] codes the simple way to work if Word is the editor; For – WinWord as editor:
vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal


So the code should be like;






Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim lngres As Long
    If InStr(1, Item.Body, “attach”) <> 0 Then
        If Item.Attachments.Count = 0 Then
            lngres = MsgBox(“‘Attach’ in body, but no attachment – send anyway?”, _
                            vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, “You Forgot to Attach File…”)
            If lngres = vbNo Then Cancel = True
        End If

    End If
End Sub


Adding_VBA_Code






Allister expanded the code a bit to include ‘enclose’ as well as ‘attach’. wow that’s cool. You can find his Useful Technology Blog for all the tips.







Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim lngres As Long
    If InStr(1, Item.Body, “attach”) <> 0 Then
        If Item.Attachments.Count = 0 Then
            lngres = MsgBox(“‘Attach’ in body, but no attachment – send anyway?”, _
                            vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, “You asked me to warn you…”)
            If lngres = vbNo Then Cancel = True
        End If
    End If
    If InStr(1, Item.Body, “enclose”) <> 0 Then
        If Item.Attachments.Count = 0 Then
            lngres = MsgBox(“‘Enclose’ in body, but no file enclosed – send anyway?”, _
                            vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, “You asked me to warn you…”)
            If lngres = vbNo Then Cancel = True
        End If
    End If
End Sub





And, finally, these 2 excellent articles by David Horowitz explain that in detail;


Did You Forget Something?


Did You Forget Something, Again?


Hope this helps.


Happy Coding,
Mohammed Athif Khaleel
MVP – Windows Server
I Blog on http://msmvps.com/athif/

7 thoughts on “Outlook Attachment Reminder Or, How to Get Outlook To Remind You to Insert a Forgotten Attachment

  1. Hi.

    I was looking for a reminderproblem in outlook.

    I use outlook with my own application (VB) and

    work with the outlookCalendar. Ok, it works.

    But there is a problem :

    If you use the reminderfunction comming up from Outlook and you say, reminder me in 3 days, it works but where stores outlook this information.

  2. My version that includes checking the subject. And searchs for the word "include".

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

    Dim lngres As Long

    If InStr(1, Item.Body, "attach") Or InStr(1, Item.Subject, "attach") <> 0 Then

    If Item.Attachments.Count = 0 Then

    lngres = MsgBox("word ‘Attach’ found, but no attachment – send anyway?", _

    vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, "You asked me to warn you…")

    If lngres = vbNo Then Cancel = True

    End If

    End If

    If InStr(1, Item.Body, "include") Or InStr(1, Item.Subject, "include") <> 0 Then

    If Item.Attachments.Count = 0 Then

    lngres = MsgBox("word ‘include’ found, but no attachment – send anyway?", _

    vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, "You asked me to warn you…")

    If lngres = vbNo Then Cancel = True

    End If

    End If

    If InStr(1, Item.Body, "enclose") Or InStr(1, Item.Subject, "enclose") <> 0 Then

    If Item.Attachments.Count = 0 Then

    lngres = MsgBox("word ‘Enclose’ found, but no file enclosed – send anyway?", _

    vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, "You asked me to warn you…")

    If lngres = vbNo Then Cancel = True

    End If

    End If

    End Sub

Leave a Reply

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