Outlook 2000, C# .Net & the Quit Event -- ApplicationEvents_Event_Quit

T

T-Man

Hey All,

I'm trying the following and it is failing with an error about unable to
complete the casting operation:

this.OutlookApplication=(Outlook.ApplicationClass)OutlookInstanceApp;
this.OutlookApplication.ApplicationEvents_Event_Quit+=new
Outlook.ApplicationEvents_QuitEventHandler(OutlookApplication_ApplicationEvents_Event_Quit);


I am trying to build this for Outlook 2000 & later and figured that the
plain 'Quit' event rather than the one labeled as '10' would be what I
needed.

Any ideas?

Regards,

TC
 
T

Tom Rizzo [MSFT]

You have to use the 10 one since it's an ambiguous name. A piece of a
chapter from my book explains this:

To show you a really simple example of an add-in, I created a simple add-in
that just sends mail when Outlook starts up. There are a couple of things
you will notice in the code below that you should take note with. First, in
the oConnection subroutine, you will notice the type cast of the variable
oMailItem which is an OutlookMailItem object to Outlook._MailItem before we
can successfully call the Send method. The reason for this is that the word
Send is ambiguous between the Outlook MailItem object and the Send event on
the Outlook Items collection. So, you need to explicitly tell .NET that you
want to call the Send method and are not implementing the Send event. This
is the reason why the variable is explicitly type-cast to an
Outlook._MailItem object.



CType(oMailItem, Outlook._MailItem).Send()



Tom
 

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