Re: MailItem.Send event (not the method)

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm



"jamiec" <jamiec@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:15B809A1-BE4B-4FA2-93F4-41E9C6C263D5@xxxxxxxxxxxxxxxx
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


"jamiechen168@xxxxxxxxx" wrote:

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



.



Relevant Pages

  • Re: Security Message When Accessing SentOnBehalfOfName
    ... Private SentEntryID As String ... Private MailItem As Outlook.MailItem ... 'Gets the Shared Account Sent Folder ... OutlookSpy - Outlook, CDO ...
    (microsoft.public.outlook.program_vba)
  • Re: Reply/Reply All
    ... OutlookSpy - Outlook, CDO ... Dim selectedItems As New System.Collections.ArrayList ... Public mailItem As Outlook.MailItem = Nothing ... "Dmitry Streblechenko" wrote: ...
    (microsoft.public.outlook.program_vba)
  • Re: Out of memory errors during operation that processes all messages
    ... checking the UnRead property of a couple hundred MailItem objects in my ... there are 6000+ handles open by Outlook. ... int FixDatesForFolder(Outlook.MAPIFolder folder, bool subfolders) ...
    (microsoft.public.outlook.interop)
  • Problem altering/saving moved MailItems in Outlook VBA
    ... what I believe is a bug in Outlook, but the workaround is not apparent to me. ... I performed a Google search but could not find a workaround to this problem. ... Function MoveEmailItemToFolder(objEmailMessage As MailItem, strFolder As ... ' This function moves the supplied email message to the specified ...
    (microsoft.public.office.developer.outlook.vba)
  • Problem altering/saving moved MailItems in Outlook VBA
    ... what I believe is a bug in Outlook, but the workaround is not apparent to me. ... I performed a Google search but could not find a workaround to this problem. ... Function MoveEmailItemToFolder(objEmailMessage As MailItem, strFolder As ... ' This function moves the supplied email message to the specified ...
    (microsoft.public.office.developer.outlook.vba)