Catch the event when Mail is sent from Outlook

A

apondu

Hi,

I am working on outlook and building an ADD-IN for outlook using
C#.Net.

I wanted to catch the event whenever a mail is sent using the outlook
and popup a messagebox showing whether to continue sending the mail or
not. I want to do it using c#.net and i am not interested by any
features (if present) of outlook that would make the task easy.

I tried using the following code but there was an error

outlook.application applicationObject = null

and code the following

public void OnStartupComplete(ref System.Array custom)
{
try
{
applicationObject.ItemSend += new
outlook.ApplicationEvents_11_ItemSendEventHandler(mailButtoon_Click);

}
catch(Exception error)
{
messagebox(error.message.tostring());
}

public void mailButton_Click(object item, ref Bool Cancel)
{
messagebox.show("Sending Message");
}


This code gives an error sometimes saying mailButton_Click without
paranthesis and sometimes won't trigger when the event occurs and if it
is triggered is gives a error message saying "No Such Interface
Supported"

Can anyone help me in this and if possible a code snippet to do this
task

I am creating a Add-In

Thanks for the help

Regards,
Govardhan
 
P

Peter Karlström

Hi Govardhan

Have you tried to catch the event theMailItem_Send(Cancel As Boolean)

I use it in VB6 and theMailItem is declared as an Outlook.MailItem and
WithEvents to catch the sending of the mail.

Maybe you can "translate" this to C#.

Regards
 
A

apondu

Hi,

Thanks for the reply. Can u give me a code snip so that i can try to
use it and convert it into C#.Net code.It would be very helpful.

Thank for responding

Govardahan
 

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