You are here:   Articles > Outlook
  |  Login

Programming Articles

Minimize
08

This code uses the Outlook Application_ItemSend Event to check the email message before sending.

To get the code to run you must have the proper security setup. For self signing a certificate see Outlook-Macros.blogspot.com or Enable Outlook macros by self signing a certificate with selfcert.exe.

This code initializes the Outlook_Email_Item_Send_Class that does all the work for checking the email message.

To get this code to work, you have to do these things.

  1. In Outlook go to Tools, Macro, Visual Basic Editor, right click Project 1, Insert, Module. Change the module name to Outlook_Email_Item_Send_Class by clicking on the module name in the properties window which by default is in the lower part of the left side. Copy the code from Outlook_Email_Item_Send_Class that is here.
  2. Click the ThisOutlookSession object and copy the code below for the Application_ItemSend Event.
  3. After the line than starts Set emailchecker, change any of the emailchecker properties that appeal to you. 
  4. Enable Outlook macros by self signing a certificate with selfcert.exe
  5. Send an email and hope this works. Good luck.

'----------------------------------------------------
'Calls the Outlook_Email_Item_Send_Class to check the email
'----------------------------------------------------
Private Sub Application_ItemSend(ByVal item As Object, cancel As Boolean)
    Dim email As mailitem
    Set email = item
    If email.Class <> olMail Then Exit Sub 'Make sure it is a mail message and not a task or something else
    Dim emailchecker As Outlook_Email_Item_Send_Class
    Set emailchecker = New Outlook_Email_Item_Send_Class
    If Not emailchecker.Item_Send_Check(email) Then
        cancel = True
        email.Display
    End If
End Sub
 

Posted in: Outlook

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.

Programmer Newsletter

Minimize

Subscribe to the Internet Handholding newsletter



Reccomend Programmer.bz

Minimize

Share/Bookmark Bookmark and Share