Q: How to Intercept "Send" Button?

K

Kyle Ferrio

Please indulge me in a naive question. I'm new to this and only vaguely
familiar with the Outlook object model.

I want my VBA code to execute /after/ the user clicks the "Send" button on
each individual email and /before/ the email is actually sent. Depending on
the content of the message, my VBA code will do something. So it's kind of
like the built-in spell-checker.

Where should I look to start traching myself how to do this?

Thanks,
Kyle
 
S

Sue Mosher [MVP-Outlook]

Use the Application.ItemSend event, e.g. :

Private Sub Application_ItemSend _
(ByVal Item As Object, Cancel As Boolean)
Dim strMsg As String
Dim res As Long
If Item.Subject = "" Then
Cancel = True
strMsg = "Please fill in the subject before sending."
MsgBox strMsg, _
vbExclamation + vbSystemModal, "Missing Subject"
Item.Display
End If
End Sub


And for VBA basics, see http://www.outlookcode.com/d/vbabasics.htm


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Coatimundi

Ms. Mosher:

This is spot-on. I suppose this is all in your book, which I should
probably pick up in my next book-order.

Thanks!
Kyle
 

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