Email outbound attachment prompt

I would like to setup a way to prompt a user upon sending an email with an attachment (particularily .doc and .docx) to remind them to convert the document to .pdf first before sending.  I don't want to deny them, just notify them, because sometimes the Word document does need to be sent.

Is their a policy, script, Outlook add in or separate application that can do this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
Hi, pcguy07.

The script below will do what you've described.  Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Here's how this works.

1.  The user creates and sends a message.
2.  When the user clicks Send Outlook fires the ItemSend event.
3.  The code in ItemSend checks all file attachments.  If any of them end with .doc or .docx, then the script displays the warning and offers the user the ability to cancel the send.  If the user cancels the send, then the message is left open on the screen.  The user can detach the Word document(s) and replace it/them with Acrobat versions.  

One intriguing possibility would be to add code that automatically converts Word documents to Acrobat format rather than asking the user if they want to abort the send.  Just a thought.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkAtt As Outlook.Attachment
    For Each olkAtt In Item.Attachments
        If olkAtt.Type <> olEmbeddeditem Then
            If (Right(LCase(olkAtt.FileName), 4) = ".doc") Or (Right(LCase(olkAtt.FileName), 5) = ".docx") Then
                'Edit the message on the next line as desired'
                If msgbox("This message has one or more Word documents attached.  You should convert them to Adobe Acrobat format (.pdf) before sending.  Would you like to cancel sending and convert the files?", vbQuestion + vbYesNo, "Document Send Warning") = vbYes Then
                    Cancel = True
                End If
                Exit For
            End If
        End If
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pcguy07Author Commented:
This is absolutely perfect.  I appreciate the quick response and the details for implementing.
Couple of questions:  I don't trust that the users will select enable macros so I want to setup for No security check.  I know it is not as safe but we have a mail filtering service and are very protected.  Is there another reason that No security check will affect this?
Also, what would you recommend for deploying this macro to each workstation?  GPO, script or manual configuration?
Thanks again
David LeeCommented:
You're welcome.  Glad I could help.

No, there's no other concerns about setting Outlook for no security check.  

Unfortunately there is no built-in means of deploying Outlook macros.  GPO's work against the registry and it's not possible to add macro code via scripting.  If you are certain that none of the employees have any Outlook macros now, then you can use a logon script to overwrite the file that Outlook macros are stored in.  Here's what you'd do.

1.  Manually add the macro on your computer.
2.  Exit Outlook.
3.  Copy the file VbaProject.OTM.  On a Vista computer you'll find the file in the folder
    On a XP computer it'll be in the folder
        c:\Documents and Settings\<username>\Application Data\Microsoft\Outlook\
4.  Add commands to a logon script that overwrites VbaProject.OTM with your copy.

If you overwrite the existing VbaProject.OTM and it contains any macro code, then it'll be lost.  That's why you need to be confident that your employees don't have any macros.  Unfortunately VbaProject.OTM is in a unique format making it impossible to write to the file directly.
pcguy07Author Commented:
That worked great.  I configured GP for Outlook's Macro security level, saved the VbaProject.OTM file to \\domain\netlogon in a distribution folder.  It correctly copied and implemented.  Here is the final prompt - Thanks again!!!

David LeeCommented:
Cool.  Glad it worked.  You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.