MailItem.Send event (not the method)

J

jamiechen168

Hello,

I am using .NET C# with VS 2005 for Outlook automation.

Can someone explain me how to use MailItem.Send event correctly?
What I discovered is MailItem inherits ItemEvents_10_Event interface
and _MailItem interface and both have "Send" defined. And _MailItem's
Send obscures ItemEvents_10_Event's Send.

MailItem
|
+ ItemEvents_10_Event (where "Send" is defined as an event) <= This
is what I need
+ _MailItem (where "Send" is defined as a method)

Even if I try to cast MailItem to ItemEvents_10_Event, I got a null for
it. Below is the example code,

// Below outLookEvent will turn to be null.
Outlook.ItemEvents_10_Event outLookEvent =
(Outlook.ItemEvents_10_Event) mailItem;
outLookEvent.Send += new .....

Does anyone ever use MailItem.Send event successfully?

Thanks
 
G

Guest

Hello,

Can someone who is knowledgeable in this area help me with this? Perhaps
those MVPs know how to use MailItem.Send event correctly in C#.

Thanks
 
K

Ken Slovak - [MVP - Outlook]

I'd probably use code something like this (VS 2005, C#):

private Outlook.MailItem m_Mail;
m_Mail = Outlook.MailItem;

m_Mail.Send += new
Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(m_Mail.Send);

I'd declare m_mail at a module level of a class that won't go out of scope
so it won't get garbage collected. I might also add it to a hashtable to
keep it alive.
 
B

Brian Tillman

jamiec said:
Can someone who is knowledgeable in this area help me with this?
Perhaps those MVPs know how to use MailItem.Send event correctly in
C#.

You'd be more likely to to encounter those knowledgeable people in a
programming group like
news://msnews.microsoft.com/microsoft.public.outlook.program_vba
 

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