?
Solved

Checking outgoing messages for attachments

Posted on 2006-05-05
1
Medium Priority
?
179 Views
Last Modified: 2010-04-08
Hello. I would like to check when people press the 'Send' button (on a new message) that

If any of the words 'enclosed, attached or attachment' are in the body of the email then it checks to see whether an attachment is present, and if not it alerts the user of this fact and gives them a chance to attach a file (or ignore the warning)
0
Comment
Question by:butterhook
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 16616122
Greetings, butterhook.

This one is pretty simple.  Here's the code.  This must go in the ThisOutlookSession module.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim arrWords As Variant, _
        strWord As Variant, _
        intResponse As Integer
    If Item.Class = olMail Then
        If Item.Sent = False Then
            arrWords = Array("enclosed", "attached", "attachment")
            For Each strWord In arrWords
                If InStr(1, LCase(Item.Body), strWord) > 0 Then
                    If Item.Attachments.Count = 0 Then
                        intResponse = MsgBox("Did you forget to attach something?", vbYesNo + vbExclamation, "Attachment Check")
                        If intResponse = vbYes Then
                            Cancel = True
                        End If
                    End If
                    Exit For
                End If
            Next
        End If
    End If
End Sub

Cheers!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question