473,320 Members | 2,020 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,320 software developers and data experts.

Outlook automation using managed code

Max
Hi,

I would like to have a button and a combo box with options to select various versions of Microsoft Outlook: 2002, 2003.
The user selects the email client and clicks the button. The only things happening will be: a new email is created and some text is
placed in the body, then the email window is displayed. The user can close the window or select some recipients and send the
message.
I would like some info on how to do this correctly. Is the best way to do this using early binding or late binding?

If I work with early binding, then what is the correct way of doing this? Right now I installed the Office 2003 PIAs from the link
below:

http://www.microsoft.com/downloads/d...displaylang=en

and I added a reference to Microsoft Outlook 11.0 Object Library to my project. Was this the right way to do it? Is installing the
above the same as getting the Office 2003 PIAs through the Office 2003 setup feature? I am beginning to think that it is not and I
have to manually remove these from the GAC and do a repair and get them through Office 2003.

For what I need to do which is just open an email and put some text in it then let the user continue, will the 2003 version of
Outlook PIA be enough to support both MS Outlook 2002 and 2003 or do I have to rely on late binding? The setup project is adding
dependencies to the dlls used and they go with the application. Is this the right way to do it or do I need to ask the user to
download the PIA's from the link above as well?

Thanks,
Max

Nov 17 '05 #1
4 5076
You'll need to use late binding. You can use early binding, but then you'll
have to bind to all the different versions.

Personally, I've found binding to Outlook (and other Office app) stuff to be
a pain in the ass because of the different versions and the massive changes
that happen from version to version. It tends to require very different code
for each version which can be a big pain.

Pete

"Max" <ma******@yahoo.com> wrote in message
news:Ok*************@tk2msftngp13.phx.gbl...
Hi,

I would like to have a button and a combo box with options to select
various versions of Microsoft Outlook: 2002, 2003.
The user selects the email client and clicks the button. The only things
happening will be: a new email is created and some text is placed in the
body, then the email window is displayed. The user can close the window or
select some recipients and send the message.
I would like some info on how to do this correctly. Is the best way to do
this using early binding or late binding?

If I work with early binding, then what is the correct way of doing this?
Right now I installed the Office 2003 PIAs from the link below:

http://www.microsoft.com/downloads/d...displaylang=en

and I added a reference to Microsoft Outlook 11.0 Object Library to my
project. Was this the right way to do it? Is installing the above the same
as getting the Office 2003 PIAs through the Office 2003 setup feature? I
am beginning to think that it is not and I have to manually remove these
from the GAC and do a repair and get them through Office 2003.

For what I need to do which is just open an email and put some text in it
then let the user continue, will the 2003 version of Outlook PIA be enough
to support both MS Outlook 2002 and 2003 or do I have to rely on late
binding? The setup project is adding dependencies to the dlls used and
they go with the application. Is this the right way to do it or do I need
to ask the user to download the PIA's from the link above as well?

Thanks,
Max

Nov 17 '05 #2
Max
Thanks for your reply Pete.

I have successfully used late binding to automate Outlook 2000,2002,2003. However I did not have any event handlers for catching
when the user closed the email window or sent the email and hence Outlook remained in memory since I did not clean up :)
Now that I'm trying to work my way through Inspectors and Creating Delegates I'm getting run time errors....

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message news:HJ********************@giganews.com...
You'll need to use late binding. You can use early binding, but then you'll have to bind to all the different versions.

Personally, I've found binding to Outlook (and other Office app) stuff to be a pain in the ass because of the different versions
and the massive changes that happen from version to version. It tends to require very different code for each version which can be
a big pain.

Pete

"Max" <ma******@yahoo.com> wrote in message news:Ok*************@tk2msftngp13.phx.gbl...
Hi,

I would like to have a button and a combo box with options to select various versions of Microsoft Outlook: 2002, 2003.
The user selects the email client and clicks the button. The only things happening will be: a new email is created and some text
is placed in the body, then the email window is displayed. The user can close the window or select some recipients and send the
message.
I would like some info on how to do this correctly. Is the best way to do this using early binding or late binding?

If I work with early binding, then what is the correct way of doing this? Right now I installed the Office 2003 PIAs from the
link below:

http://www.microsoft.com/downloads/d...displaylang=en

and I added a reference to Microsoft Outlook 11.0 Object Library to my project. Was this the right way to do it? Is installing
the above the same as getting the Office 2003 PIAs through the Office 2003 setup feature? I am beginning to think that it is not
and I have to manually remove these from the GAC and do a repair and get them through Office 2003.

For what I need to do which is just open an email and put some text in it then let the user continue, will the 2003 version of
Outlook PIA be enough to support both MS Outlook 2002 and 2003 or do I have to rely on late binding? The setup project is adding
dependencies to the dlls used and they go with the application. Is this the right way to do it or do I need to ask the user to
download the PIA's from the link above as well?

Thanks,
Max



Nov 17 '05 #3
Max
The error I'm getting at runtime says:

System.ArgumentException: Error binding to target method.
at System.Delegate.InternalCreate(Object target, String method, Boolean ignoreCase)
at System.Delegate.CreateDelegate(Type type, Object target, String method)

and it happens on the last line of this code:

Expand|Select|Wrap|Line Numbers
  1. Type oType = Type.GetTypeFromProgID("Outlook.Application");
  2. oApp = Activator.CreateInstance(oType);
  3.  
  4. oInspectors = oApp.GetType().GetProperty("Inspectors").GetValue(oApp, null);
  5.  
  6. e_NewInspector = oInspectors.GetType().GetEvent("NewInspector");
  7. d_NewEventDelegate = Delegate.CreateDelegate(e_NewInspector.EventHandlerType,
  8. this, "Inspectors_NewInspector");
  9.  
The debugger loads the assemblies from the GAC. Is there anything wrong with that?

Loaded 'c:\windows\assembly\gac\microsoft.office.interop. outlook\11.0.0.0__71e9bce111e9429c\microsoft.offic e.interop.outlook.dll',
No symbols loaded.
Loaded 'c:\windows\assembly\gac\office\11.0.0.0__71e9bce1 11e9429c\office.dll', No symbols loaded.


"Max" <ma******@yahoo.com> wrote in message news:eW*************@TK2MSFTNGP15.phx.gbl...
Thanks for your reply Pete.

I have successfully used late binding to automate Outlook 2000,2002,2003. However I did not have any event handlers for catching
when the user closed the email window or sent the email and hence Outlook remained in memory since I did not clean up :)
Now that I'm trying to work my way through Inspectors and Creating Delegates I'm getting run time errors....

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message news:HJ********************@giganews.com...
You'll need to use late binding. You can use early binding, but then you'll have to bind to all the different versions.

Personally, I've found binding to Outlook (and other Office app) stuff to be a pain in the ass because of the different versions
and the massive changes that happen from version to version. It tends to require very different code for each version which can
be a big pain.

Pete

"Max" <ma******@yahoo.com> wrote in message news:Ok*************@tk2msftngp13.phx.gbl...
Hi,

I would like to have a button and a combo box with options to select various versions of Microsoft Outlook: 2002, 2003.
The user selects the email client and clicks the button. The only things happening will be: a new email is created and some text
is placed in the body, then the email window is displayed. The user can close the window or select some recipients and send the
message.
I would like some info on how to do this correctly. Is the best way to do this using early binding or late binding?

If I work with early binding, then what is the correct way of doing this? Right now I installed the Office 2003 PIAs from the
link below:

http://www.microsoft.com/downloads/d...displaylang=en

and I added a reference to Microsoft Outlook 11.0 Object Library to my project. Was this the right way to do it? Is installing
the above the same as getting the Office 2003 PIAs through the Office 2003 setup feature? I am beginning to think that it is not
and I have to manually remove these from the GAC and do a repair and get them through Office 2003.

For what I need to do which is just open an email and put some text in it then let the user continue, will the 2003 version of
Outlook PIA be enough to support both MS Outlook 2002 and 2003 or do I have to rely on late binding? The setup project is adding
dependencies to the dlls used and they go with the application. Is this the right way to do it or do I need to ask the user to
download the PIA's from the link above as well?

Thanks,
Max



Nov 17 '05 #4
Honestly, it would be hard to say. The last time I used outlook was a couple
versions back (wrote an app that notified me of new mail with a voice
synthesizer that spoke the name and subject of the e-mail).

The assemblies you're using are definitely different than the ones I used. I
don't recall creating any delegates, per se. The only thing I did was
subscribe to the NewMailEventHandler which was as simple as something like
this:

applicationObject.Application.NewMail +=
new
Outlook.ApplicationEvents_NewMailEventHandler(Appl ication_NewMail);

From my version of the API, I would think that all you'd have to do is:

oApp.Application.Inspectors.NewInspector +=
Outlook.InspectorEvents_NewInspectorEventHandler(M y_NewInspector)

and then add an event handler called My_NewInspector.

Now, maybe I did mine differently than you're doing yours.

I had a class that implemented Extensibility.IDTExtensibility2. It also had
a ProgID and Guid and was registered for COM interop.

Honestly I don't remember the specifics. I wrote this thing back in 2003.

If you'd like to look at the code, though, you can download it here:
http://www.petedavis.net/downloads/SpokenMail.zip

Pete
"Max" <ma******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
The error I'm getting at runtime says:

System.ArgumentException: Error binding to target method.
at System.Delegate.InternalCreate(Object target, String method, Boolean
ignoreCase)
at System.Delegate.CreateDelegate(Type type, Object target, String
method)

and it happens on the last line of this code:

Expand|Select|Wrap|Line Numbers
  1.  Type oType = Type.GetTypeFromProgID("Outlook.Application");
  2.  oApp = Activator.CreateInstance(oType);
  3.  oInspectors = oApp.GetType().GetProperty("Inspectors").GetValue(oApp,
  4.  null);
  5.  e_NewInspector = oInspectors.GetType().GetEvent("NewInspector");
  6.  d_NewEventDelegate =
  7.  Delegate.CreateDelegate(e_NewInspector.EventHandlerType,
  8.        this, "Inspectors_NewInspector");
  9.  

The debugger loads the assemblies from the GAC. Is there anything wrong
with that?

Loaded
'c:\windows\assembly\gac\microsoft.office.interop. outlook\11.0.0.0__71e9bce111e9429c\microsoft.offic e.interop.outlook.dll',
No symbols loaded.
Loaded
'c:\windows\assembly\gac\office\11.0.0.0__71e9bce1 11e9429c\office.dll', No
symbols loaded.


"Max" <ma******@yahoo.com> wrote in message
news:eW*************@TK2MSFTNGP15.phx.gbl...
Thanks for your reply Pete.

I have successfully used late binding to automate Outlook 2000,2002,2003.
However I did not have any event handlers for catching when the user
closed the email window or sent the email and hence Outlook remained in
memory since I did not clean up :)
Now that I'm trying to work my way through Inspectors and Creating
Delegates I'm getting run time errors....

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:HJ********************@giganews.com...
You'll need to use late binding. You can use early binding, but then
you'll have to bind to all the different versions.

Personally, I've found binding to Outlook (and other Office app) stuff
to be a pain in the ass because of the different versions and the
massive changes that happen from version to version. It tends to require
very different code for each version which can be a big pain.

Pete

"Max" <ma******@yahoo.com> wrote in message
news:Ok*************@tk2msftngp13.phx.gbl...
Hi,

I would like to have a button and a combo box with options to select
various versions of Microsoft Outlook: 2002, 2003.
The user selects the email client and clicks the button. The only
things happening will be: a new email is created and some text is
placed in the body, then the email window is displayed. The user can
close the window or select some recipients and send the message.
I would like some info on how to do this correctly. Is the best way to
do this using early binding or late binding?

If I work with early binding, then what is the correct way of doing
this? Right now I installed the Office 2003 PIAs from the link below:

http://www.microsoft.com/downloads/d...displaylang=en

and I added a reference to Microsoft Outlook 11.0 Object Library to my
project. Was this the right way to do it? Is installing the above the
same as getting the Office 2003 PIAs through the Office 2003 setup
feature? I am beginning to think that it is not and I have to manually
remove these from the GAC and do a repair and get them through Office
2003.

For what I need to do which is just open an email and put some text in
it then let the user continue, will the 2003 version of Outlook PIA be
enough to support both MS Outlook 2002 and 2003 or do I have to rely on
late binding? The setup project is adding dependencies to the dlls used
and they go with the application. Is this the right way to do it or do
I need to ask the user to download the PIA's from the link above as
well?

Thanks,
Max

Nov 17 '05 #5

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

Similar topics

7
by: MLH | last post by:
Is the following remotely correct? =DDE("C:\Program Files\Program Files\Outlook Express\OEmig50","Attachment","Name") I'm not sure that OEmig50.exe is the executable for OE. Anybody know? ...
10
by: John | last post by:
Hi When I open a new outlook email from vb.net, sometimes outlook is very slow to appear or occasionally outlook freezes completely. I am targeting mixed office2000/xp environments so I am...
26
by: Tom Becker | last post by:
Is there a way, from Access, to programmatically click the Send and Receive button in Outlook?
5
by: Arno R | last post by:
Hi all, I need to get at specific (shared) agenda-data from MS outlook 2003. I need every day to get the scheduled 'appointments' for some rooms to Access. In Access I will show the...
0
by: salad | last post by:
I'm on A97 and have Outlook 2003 on the computer. There's some generic code at Tony Toew's site and at MS and on the web that's very similar....but I can't make it work. I want to use late...
9
by: H. Dederichs | last post by:
Hello NG, I would like to read and write Outlook PST-Files with my VB.NET application natively. Is there anyone who can help me with this issue? Since PST-Files are "also" Databases, aren't...
1
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
0
by: madihamir | last post by:
Iam new to .net and have gotten assignment for make the class library to automate the outlook I have tried to done it but i've to make the Handlers also . Detecting an methods for receiving and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.