473,725 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5105
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******** *****@tk2msftng p13.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******** ************@gi ganews.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******** *****@tk2msftng p13.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.Argument Exception: 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\ass embly\gac\micro soft.office.int erop.outlook\11 .0.0.0__71e9bce 111e9429c\micro soft.office.int erop.outlook.dl l',
No symbols loaded.
Loaded 'c:\windows\ass embly\gac\offic e\11.0.0.0__71e 9bce111e9429c\o ffice.dll', No symbols loaded.


"Max" <ma******@yahoo .com> wrote in message news:eW******** *****@TK2MSFTNG P15.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******** ************@gi ganews.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******** *****@tk2msftng p13.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 NewMailEventHan dler which was as simple as something like
this:

applicationObje ct.Application. NewMail +=
new
Outlook.Applica tionEvents_NewM ailEventHandler (Application_Ne wMail);

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

oApp.Applicatio n.Inspectors.Ne wInspector +=
Outlook.Inspect orEvents_NewIns pectorEventHand ler(My_NewInspe ctor)

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.I DTExtensibility 2. 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******** ********@TK2MSF TNGP10.phx.gbl. ..
The error I'm getting at runtime says:

System.Argument Exception: 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\ass embly\gac\micro soft.office.int erop.outlook\11 .0.0.0__71e9bce 111e9429c\micro soft.office.int erop.outlook.dl l',
No symbols loaded.
Loaded
'c:\windows\ass embly\gac\offic e\11.0.0.0__71e 9bce111e9429c\o ffice.dll', No
symbols loaded.


"Max" <ma******@yahoo .com> wrote in message
news:eW******** *****@TK2MSFTNG P15.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******** ************@gi ganews.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******** *****@tk2msftng p13.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
5412
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? I find no list of TOPICS to use with the DDE related commands in Access Basic or VBA
10
2852
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 using the office2000 interop dlls generated by vs.net by adding office 2000 com reference. Any one else noticed this problem when targeting office2000/xp mixed environments? Is there a better, more robust way to do this? Am I better off using late...
26
4503
by: Tom Becker | last post by:
Is there a way, from Access, to programmatically click the Send and Receive button in Outlook?
5
3326
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 time-periods that the rooms are booked for that day. I know how to code all this in Access. I can show some testdata for 5 rooms quite nicely on a form. I never ever needed to use Outlook-to-Access before, so I need a good starting point to get the data.
0
1449
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 binding but it appears I'm not having much luck. The code works ONLY if Outlook is loaded. I'm a bit unfamiliar with Outlook...been using Netscape for way too long. When I start Outlook, it prompts me for a profile. How do you handle that via...
9
14600
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 they? Maybe there ist a way to do this with an Active Sync API if existing? Hints with sample are highly appreciated. B.T.W.
1
3223
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 and server (Exchange server mail box) to connect and then save the mailitems(from Inbox or any other folder) based on a filter to a*.msg file. I want to achieve this using only one Interop dll if this is possible. Tried so far:
1
2869
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 and server (Exchange server mail box) to connect and then save the mailitems(from Inbox or any other folder) based on a filter to a*.msg file. I want to achieve this using only one Interop dll if this is possible. Tried so far:
0
1598
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 sending things to outlook.. and OutlookHandler has a list of outlookmessages for example I know that outlookHandler will typically have methods like the following
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.