Outlook Send Event

K

Kathleen

Please help if you can,

I am trying to get a MsgBox to display when the word "attachment" is found
in a new message. I cannot seem to get it to "hook" in to the Send Event. I
am missing something here. Macro security is set to Low. This is the code:

Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim intRetval As Integer
' Look for the string "attach" in the body of the message

If InStr(UCase(Item.Body), "ATTACH") Then

' See if there is an attachment
If Item.Attachments.Count = 0 Then

' Ask the user whether Send should be canceled
intRetval = MsgBox("You used the word 'attach'. " & _
"Did you mean to include an attachment?", _
vbYesNo)
If intRetval = vbYes Then
Cancel = True
End If
End If
End If
End Sub


Tia,
Kathy
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Kathleen > écrivait :
In this message, < Kathleen > wrote:

|| Please help if you can,
||
|| I am trying to get a MsgBox to display when the word "attachment" is
found
|| in a new message. I cannot seem to get it to "hook" in to the Send Event.
I
|| am missing something here. Macro security is set to Low. This is the
code:
||
|| Private Sub Application_ItemSend(ByVal Item As Object, _
|| Cancel As Boolean)
|| Dim intRetval As Integer
|| ' Look for the string "attach" in the body of the message
||
|| If InStr(UCase(Item.Body), "ATTACH") Then
||
|| ' See if there is an attachment
|| If Item.Attachments.Count = 0 Then
||
|| ' Ask the user whether Send should be canceled
|| intRetval = MsgBox("You used the word 'attach'. " & _
|| "Did you mean to include an attachment?", _
|| vbYesNo)
|| If intRetval = vbYes Then
|| Cancel = True
|| End If
|| End If
|| End If
|| End Sub
||

This is a Word VBA group. Try your luck in an Outlook group, such as:
microsoft.public.office.developer.outlook.vba

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top