Microsoft Outlook:  VBA Code to Integrate Dialog Box Message, User Activity, and Existing Rule

axla
axla used Ask the Experts™
on
Experts

In my company we have "regulatory walls" between different work groups to prevent priveliged information from being shared across different organizations.  A simple example is that we have Work Groups:  A, B, and C.  Employess from Work Group A can freely communicate electronically with Employees from Work Group B or Work Group C.  Work Group B and Work Group C employees can not freely communicate with each other electronically.

I created a Rule in Outlook that checks the text body of incoming E-Mail messages against a list of test individuals such that when it finds one of the names in the list it changes the color of the E-Mail flag to "blue".

What I'm wondering is if it's possible, in Outlook VBA, to duplicate or use the existing rule to work so that it would run this rule before sending any out-going E-Mail messages.  The code, before turning the E-Mail flag to blue or instead of turning the E-Mail flag to blue, would present the user with a warning message indicating that the text body of the out-going E-Mail message contains one or more names from the restricted employee list.  The warning message dialog box would also have "Yes" and "No" buttons the employee would have to select in order to proceed, indicating whether or not they want to proceed with sending the E-Mail message.  The code would also capture the employee_name, employee_selection, employee_id, and organization information to serve as an audit trail to identify when employees select the "Yes" button and choose to send the message without revisions.  Any help you can provide would be greatly appreciated.  Thank you in advance for your help.

axla
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
Hi, axla.

What version of Outlook are you using?

Author

Commented:
BlueDevilFan,

We are using Microsoft Outlook 2003 (11.8206.8221) SP3

axla
An Outlook MailItem has a "send" event.  So use this.  The event fires when the email is sent. You put your question in this events routines.  It has a Cancel so if the user chooses NO then you can cancel the sending of the email.

It seems you have most of the code to check the email and change some of its properties like the flag color so you can cut and copy this code.

If they in fact continue to send the email, before letting the email go out you would have to get all these new properties of the email out before they send it.

One major question is how you are going to save these things "as an audit trial", do you have a backend database you want to write to or a text file?


Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Darbid73,

Unfortunately, I've done little or no programming in the Microsoft Outlook VBA environment so I haven't even begun trying to put the code together.  I would definitely need some assistance with constructing the procedure.  I only have the rule in place within the Microsoft Outlook environment.  I have however layed around with extracting data from Outlook using Access.  Any help you can provide would be greatly appreciated.  Thanks again in advance.

axla
Ok that is not a problem - but you are doing all the work - and I am sure others will pick up on the things we do not know.

I am not sure about RULES and whether you should continue to use this rule or whether we code the lot in VBA.  I suppose you will have to decide this.

So open your VB editor for outlook and play around with it.


I will put a kind of plan below of what you should start to do.  The send event is going to come from Application_ItemSend as you can see below.




Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
 
 
'If the body of the email includes cetain names then
 
	'set up a YES/NO message box with the question if they still want to send.
	
	'If No Then
			Cancel = True   'this will cancel the send
	'End If
	
	'If YES Then
		
		'get all the details of the email you need
		'maybe write them to a database or what ever you think
		
		
	'End If
 
 
'End if
 
 
 
End Sub

Open in new window

Author

Commented:
Darbid73,

Thanks for the start, this is a big help.  Since the rule I created in Outlook is already using an "out of the box" process for scanning the text body of the E-Mail, is there a way to find out which process the rule calls/uses in Outlook and duplicate that call from within the code block?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial