473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Outlook ItemSend event

Hi -

I am developing an application that needs to automate Microsoft Outlook and
I need to capture the ItemSend event. The PC I'm developing with has Outlook
2003 on; the problem I have is I need to make the code work with Outlook XP
(i.e. 2002)!

The code to add the event is currently:

oOutlook.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler
(oOutlook_ItemSend);

This works fine for Outlook 2003, but causes an 80040200 exception when used
with a computer running Outlook XP!

Changing the above to:

oOutlook.ItemSend += new Outlook.ApplicationEvents_10_ItemSendEventHandler
(oOutlook_ItemSend);

Causes a compilation error (cannot convert to
ApplicationEvents_11_ItemSendEventHandler).

I've also tried:

oOutlook.ItemSend += new Outlook.ApplicationEvents_ItemSendEventHandler
(oOutlook_ItemSend);

With essentially the same error as above being generated.

Can anyone shed any light on what I need to do to create an event that will
work with Outlook 2003 and XP?

TIA

- Andy
Nov 15 '05 #1
4 10056
Andy,
I have not really done any cross version Outlook in .NET yet.

I believe you need to use the ApplicationEvents_10 events instead of the
ApplicationEvents_11 events.

The following site provides a number of articles on using Outlook from .NET.

http://www.microeye.com/resources/res_outlookvsnet.htm

Have you tried?
oOutlook.ApplicationEvents_10_ItemSend += new Outlook.ApplicationEvents_10_ItemSendEventHandler (oOutlook_ItemSend);

Again I do not have both versions loaded to try the above.

Hope this helps
Jay

"Andy Bates" <An********@UltimateSoftwareSolutions.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi -

I am developing an application that needs to automate Microsoft Outlook and I need to capture the ItemSend event. The PC I'm developing with has Outlook 2003 on; the problem I have is I need to make the code work with Outlook XP (i.e. 2002)!

The code to add the event is currently:

oOutlook.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler
(oOutlook_ItemSend);

This works fine for Outlook 2003, but causes an 80040200 exception when used with a computer running Outlook XP!

Changing the above to:

oOutlook.ItemSend += new Outlook.ApplicationEvents_10_ItemSendEventHandler
(oOutlook_ItemSend);

Causes a compilation error (cannot convert to
ApplicationEvents_11_ItemSendEventHandler).

I've also tried:

oOutlook.ItemSend += new Outlook.ApplicationEvents_ItemSendEventHandler
(oOutlook_ItemSend);

With essentially the same error as above being generated.

Can anyone shed any light on what I need to do to create an event that will work with Outlook 2003 and XP?

TIA

- Andy

Nov 15 '05 #2
Andy,
In addition to my other post, I am checking with some others for further
information or confirmation on my answer.

Hope this helps
Jay

"Andy Bates" <An********@UltimateSoftwareSolutions.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi -

I am developing an application that needs to automate Microsoft Outlook and I need to capture the ItemSend event. The PC I'm developing with has Outlook 2003 on; the problem I have is I need to make the code work with Outlook XP (i.e. 2002)!

The code to add the event is currently:

oOutlook.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler
(oOutlook_ItemSend);

This works fine for Outlook 2003, but causes an 80040200 exception when used with a computer running Outlook XP!

Changing the above to:

oOutlook.ItemSend += new Outlook.ApplicationEvents_10_ItemSendEventHandler
(oOutlook_ItemSend);

Causes a compilation error (cannot convert to
ApplicationEvents_11_ItemSendEventHandler).

I've also tried:

oOutlook.ItemSend += new Outlook.ApplicationEvents_ItemSendEventHandler
(oOutlook_ItemSend);

With essentially the same error as above being generated.

Can anyone shed any light on what I need to do to create an event that will work with Outlook 2003 and XP?

TIA

- Andy

Nov 15 '05 #3

Hi Andy,

I can succeed trap the ItemSend event through the 2 ways below:

//Add the reference of "Microsoft Outlook 10.0 Object Library" first.
private void button2_Click(object sender, System.EventArgs e)
{
Outlook.ApplicationClass obj=new Outlook.ApplicationClass();
obj.ItemSend+=new
Outlook.ApplicationEvents_10_ItemSendEventHandler( obj_ItemSend);
obj.ApplicationEvents_Event_ItemSend+=new
Outlook.ApplicationEvents_ItemSendEventHandler(obj _ItemSend);
}

private void obj_ItemSend(object sender,ref bool arg)
{
MessageBox.Show("ItemSent");
}

The ItemSent messagebox will show 2 times, which means that these 2
approaches both work.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
I'm working on a similar problem.

I think the class you want to use is an Outlook.ApplicationClass rather
than the Outlook.Application.

The Outlook.Application object is specific to the library you
referenced. If you are referencing the XP library, you'll get XP
objects, which have _10_ in them. If you use the 2003 library, you'll
get 2003 objects, which have the _11_ in them. Unfortunately, these
libraries are NOT backward compatible, so when you go to run on older
versions of outlook, your application will not work.

There is an Outlook.ApplicationClass object which has generic event
handlers which (I think) are supposed to work across versions. Instead
of using the Outlook.Application.ItemSend event, you'll use the
Outlook.ApplicationClass.ApplicationEvents_Event_I temSend event.

But - the caveat! For me (and this is where I am stuck), I can't get
the ApplicationClass object. If you run as Outlook automation, I think
you can just create your own:
Outlook.ApplicationClass foo = new Outlook.ApplicationClass();

but, if you are running as an outlook add-in (which I am), this whole
thing doesn't seem to work. (You get a Invalid Cast exception when you
try). I'm referencing the Outlook 10 libraries. I'm also finding that
when running as an Outlook Add-In, even if you do use the ItemSend event
(rather than the cross-version event handler), setting the Cancel flag
doesn't work.

Hope this helps. If anyone has any ideas on my problem, that would be
great!!!

Thanks,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Belshe | last post by:
I've got an outlook add-in. I'm running Outlook XP, .NET 1.1. My Add-In is written in C#. I'm trying to trap either the Application.ItemSend or the MailItem.ItemSend event to put up a dialog...
0
by: Martin Knauer | last post by:
Hi, I try to build an Outlook Plugin. After having some trouble with the Inspectorevents I'm trying to build a wrapper for the Inspectorclass. However I'm stuck again after letting VS.Net 2003...
1
by: Rob McCaughey | last post by:
Hi all! I'm a VB newbie, and trying to send an Outlook Task automatically without user intervention in a VB application. When I use the following code, if I enable the send portion (see code...
1
by: Paul D. Fox | last post by:
I've seen how you can send e-mail through ASP.NET, but how about sending an Outlook Calendar event after the "Submit" button is pressed? Does anyone have a small sample of this? Paul
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
0
by: SteveHasel | last post by:
I'm working in Visual Studio 2005 trying to use Outlook to create an email and display it for the user to edit and then send. I need to be able to check that the item in the ItemSend event is my item...
1
by: John | last post by:
Hi I have a simple Outlook 2003 AddIn created using Outlook 2003 AddIn template in vs 2008. The full code is given below at the end. I got warnings on Interop assemblies as I have Office 2007...
2
by: luca.gere | last post by:
How can I do an outlook style event calendar in VB.NET ? Is there a FREE component that i can use ? THank You Luca
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.