Logo: TechTrax...brought to you by MouseTrax Computing Solutions

Did You Forget Something, Again?

by David Horowitz

Or, How to Get Outlook To Remind You to Insert Forgotten Attachments
(an update to the TechTrax April 2004 article Did You Forget Something?)

I’ve received many requests to modify my article Did You Forget Something? from the April 2004 of TechTrax to enable you to easily insert more than one forgotten attachment upon hitting Send. The code in the original article showed you how to have Outlook remind you if you seem to have forgotten to insert your attachment when you send an email. It will only do this if your email contains one of several words that you can specify, such as “enclose” or “attach”. But many people pointed out a shortcoming in my original approach in that it only allowed you to insert a single forgotten attachment. But let’s say you forgot to attach all three of your desired attachments. Then you’d be stuck.

Well, not anymore. With the code in this new article, Outlook will search for the keywords and if they’re found, and you don’t have any attachments, it will display a dialog box saying, “It appears you may have forgotten to specify your attachment(s). Would you like to do this now?” as in the following screen snapshot.

Figure 1 – The Dialog Box

Your three options at this point are Yes, No or Cancel:

  • Yes: Outlook will display the Insert / File… command, allowing you to specify your first attachment. After doing so, you will be returned to your email for more editing OR for more attaching through the Insert / File… command. When you’re finally sure you’re ready to send, you should hit the Send button.

  • No: Outlook will Send your email out for you as is.

  • Cancel: You will be returned to your email for more editing. Your Send commend has been cancelled. Do whatever editing you would like, attach any files you wish, and hit Send when you’re ready.

The changes to the code have been relatively minor but they create the desired effect.

Here’s the code. For instructions about how to add code to your Outlook session, please see the original article, Did You Forget Something, TechTrax, April 2004. You'll also find important instructions in the original article about how to properly set your Outlook Macro Security settings so this code will work.

' Code Copyright (c) 2005, Soundside Inc. All Rights Reserved.
Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Class <> olMail Then Exit Sub
    If Item.Attachments.Count > 0 Then Exit Sub
    If Not SearchForAttachWords(Item.Subject & ":" & Item.Body) Then Exit Sub
    Select Case UserWantsToAttach
        Case vbYes      ' Insert and return to editing
            ExecuteInsertFileCommand
            Cancel = True
        Case vbNo       ' Just send
        Case vbCancel   ' Return to editing
            Cancel = True
    End Select
End Sub

Function SearchForAttachWords(ByVal s As String) As Boolean
    Dim v As Variant
    For Each v In Array("attach", "enclos")
        If InStr(1, s, v, vbTextCompare) <> 0 Then
            SearchForAttachWords = True
            Exit Function
        End If
    Next
End Function

Function UserWantsToAttach() As VbMsgBoxResult
    UserWantsToAttach = MsgBox("It appears you may have forgotten to specify your attachment(s)." _
            & vbCrLf & vbCrLf & _
            "Would you like to do this now?", _
            vbQuestion + vbYesNoCancel)
End Function

Sub ExecuteInsertFileCommand()
    Application.ActiveInspector.CommandBars("Standard").Controls("&File...").Execute
End Sub

Please let us know any comments, suggestions or ideas you may have! You can send Feedback through the magazine or feel free to drop me a line.

Special thanks go to faithful reader Peter Lecki for helping me decide on the exact procedure to use for this article, through his interest in having the multiple attachment feature available for himself!

Happy Emailing!

– Dave

Click to rate this article.

 

Go up to the top of this page.
This site powered by the Logical Web Publisher (TM): Fast, easy, and affordable content management