1. ATTACHMENT CHECKER
If you use Outlook 2010(or 2003, 2007) to mail someone and sometimes get replies to your
emails saying, “I think you might have forgotten the attachment,” you should check out
ATTACHMENT CHECKER, a simple VBScript macro. You don’t need to install any plugins
or any application software .This script runs when the user sends the email to someone. If the
mail expects some attachments and user just clicks on the SEND button after writing the mail(
but forgetting to attach file), a pop window will open, asking the user
If he wishes to continue sending, he can choose “YES” otherwise “NO”. This script is written to
enable user to prevent committing frequent errors of not attaching the files while mailing to
someone.
2. VB SCRIPT
Public 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") Or InStr(1,
Item.Body, "ATTACH") Or InStr(1, Item.Subject, "ATTACH") Or InStr(1, Item.Body,
"include") Or InStr(1, Item.Subject, "include") Or InStr(1, Item.Body, "INCLUDE")
Or InStr(1, Item.Subject, "INCLUDE") Or InStr(1, Item.Body, "enclose") Or InStr(1,
Item.Subject, "enclose") Or InStr(1, Item.Body, "ENCLOSE") Or InStr(1,
Item.Subject, "ENCLOSE") Or InStr(1, Item.Body, "PFA") Or InStr(1, Item.Subject,
"PFA") Or InStr(1, Item.Body, "pfa") Or InStr(1, Item.Subject, "pfa") Then
If Item.Attachments.Count = 0 Then
lngres = MsgBox("It appears that you mean to send an attachment, but there is no
attachment to this message - Do you still want to send?", _
vbYesNo + vbDefaultButton2 + vbQuestion + vbSystemModal, "Outlook Warning")
If lngres = vbNo Then Cancel = True
End If
End If
End Sub
3. Program Description
The first thing to notice is that this macro is executed whenever you click the send button (or
press ctrl-enter). Whenever you start the send process, this macro executes.
The code looks for the o ds Atta h , I lude , E lose , PFA in the body of the email as
well as in subject . Sometimes you just se d a e ail ith the su je t li e Fi al epo t
atta hed a d othi g i the od so ou ould definitely want the trigger to recognize this.
Also, the triggers can also hit o othe fo s of the o d, su h as Atta hed . “o, if o e of those
key words is found, it will then check to see if there are any attachments in the email.
If there are no attachments, a dialog box is presented stating that It appears that you
mean to send an attachment, but there is no attachment to this message -
Do you still want to send?"
If ou a s e No to the uestio Do ou still a t to se d , the the se d p o ess is
cancelled and you will have a chance to add you atta h e t. If ou hoose Yes the the
email is sent as usual.
4. How to run this script
1. Open Outlook a d he k fi st if otifi atio s fo all a os is sele ted o ot i ou OUTLOOK
Files ----->Options----->Outlook options box will be opened
Trust Center---->Trust Center Settings---->Macro Settings----->
Select notifications for all macros
2. Just copy the VB SCRIPT above to the clipboard , open Outlook and press alt-F11.
3. On the left side, you will see a standard navigation tree. Under Project1 (VbaProject.OTM)
e pa d Mi osoft Offi e Outlook O je ts. Dou le Cli k o ThisOutlook“essio a d the paste
the code in the code pane.
4. Save your work, close Outlook and restart it.
5. On starting, a pop will come
6. Click on Enable Macros . Try and test the code by sending yourself some test emails.
5. Results
On clicking Send button without attesting any file, the pop window will open up
6. FUTURE EXPECTATIONS
It can happen that you might be replying to a quoted email that someone sent you and had the word
atta h i it. Most people he the epl to a e ail, the i lude the o igi al se de ’s uoted e ail.
You may not have any intention of including an attachment in this case, but the macro will still find the
o d atta h , so it gets t igge ed. I ish the e as a a to ha e the a o o l look at the e te t
that ou added, ut the e does ’t see to e.
7. FROM THE WRITER
It has been great that I am here again to share
something with you .I am looking forward for your
responses. Your feedback means a world to me. I
am so grateful to all those blogwriters whose blogs
have helped me . To think that I've been of some
help to others, is humbling and deeply gratifying.
Thank you!
DEEPANSHU GUPTA
deepanshu.a.gupta@accenture.com