PDA

View Full Version : VBA Code - Mail send and Msgbox



weirdbeardmt
02-27-2006, 09:47 AM
Hi everyone,

I am trying to add a little checking on our Exchange server. The situation is this:

1) When a user creates a new email, I want to check the subject of the email to see if they've entered a particular phrase in there.
2) If they haven't, then I pop up an Inputbox and say "Are you sure you don't want to add this to your subject?"
3) They either click OK or Cancel - either way the mail gets sent.

Actually, this part of the code is fine - it's all sorted (i.e. intercepting the Send event) - the only problem I have is that when the inputbox pops up (same with a msgbox) then the box is BEHIND the mail message window (because it has come from the main Outlook application, not the mail window). The only way I've been able to get the msgbox on top of the mail window is to show the box like this:




VBA:

msgbox "Something here?", vbSystemModal

VBA tags courtesy of www.thecodenet.com (http://www.thecodenet.com)


but that's no good because it only gives you an OK button. So is there anyway of getting this input box to show on the top? Either minimise the mail window, or bring the Outlook application to the front or something...

We're using Outlook 2003 SP2.

Any ideas? :)
Matt

Killian
02-28-2006, 03:34 AM
Hi and welcome to VBAX :hi:

I'm not quite sure how to replicate this - in the normal course of events, a mail item is part of the app and a modal dialog of any kind (input boxes are always modal) will be on top of everything and keep the focus.
By definition, using the Application_ItemSend event to raise the message box ensures you're dealing with the correct app instance.
Unless your doing it another way?

weirdbeardmt
02-28-2006, 04:52 AM
Hi and welcome to VBAX :hi:

I'm not quite sure how to replicate this - in the normal course of events, a mail item is part of the app and a modal dialog of any kind (input boxes are always modal) will be on top of everything and keep the focus.
By definition, using the Application_ItemSend event to raise the message box ensures you're dealing with the correct app instance.
Unless your doing it another way?

Well the modal dialog is coming from Outlook, but for whatever reason that is sitting behind the mail message. I did find a workaround - I didn't know that in dialog boxes you could join the different types of buttons together, so if I do a

msgbox "Hello", vbsystemmodal OR vbyesno

then I get a modal dialog on top with yes no buttons... so it sort of works :)