Outlook MailItem - event before built-in error message

I

István Becze

I'm developing a COM add-in for Outlook 2007 using VS 2005 and VSTO 2005 SE.
The add-in has a custom mail item form with an additional textbox where I
allow the user to enter special (i.e. just username without the domain)
e-mail addresses that the COM add-in will turn into fully qualified e-mail
addresses.

My problem is, that Outlook will show a built-in error message "There must
be at least one name or distribution list in the To, Cc or Bcc box." if I
press the send button and there is no recipient entered into any of the above
fields.

I would like to either override this built-in event handler, or insert my
own event handler after the Send button is pressed, but before the built-in
message appears, so that I can format the special addresses and add them to
the recipient list. Unfortunately, both the Application.ItemSend and the
MailItem.Send event fires after the built-in error message, and I didn't find
any other events, that I could use.

Any thoughts will be appreciated.

Thanks,

István
 
K

Ken Slovak - [MVP - Outlook]

I don't know of a way to override the built-in handler in a Send event, but
you can see if the MailItem.BeforeCheckNames event does what you want.
 
I

István Becze

Thank you Ken, I cheked, but unfortunately that event is also after the
built-in error message.

István
 
K

Ken Slovak - [MVP - Outlook]

Then there's not much you can do. That dialog will appear then if Send is
clicked with no recipients. You could add one using code, but that would be
visible to the user.
 
I

István Becze

Yes, there is not much to do. I think I'll put a recipient into the BCC
field and delete it before I send the message (in the MailItem.Send event).
The good thing is that the BCC field is disabled on a custom form, but
unfortunately it can be seen on the Select Name dialog (after clicking the To
or Cc button).

I'm wondering if it is (theoretically) possible to implement a mouse click
hook and implement the functionality there. (I'm pretty sure that
implementing this is not as simple as it sounds.)

Thank you again, for your help,

István
 
K

Ken Slovak - [MVP - Outlook]

Theoretically you can intercept any messages directed to an Outlook window
from the keyboard (don't forget shortcuts) or the mouse. The problem is
knowing what the messages are saying and intercepting the correct window's
messages. It's not something I'd want to be tasked with coding.
 

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