By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,166 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,166 IT Pros & Developers. It's quick & easy.

VB.NET & Various Versions Of Outlook

P: n/a
Hi everyone. Having problems with a utility I am writing for work.
The previous IT Director thoughtfully allowed 3 (2000, xp, 2003)
versions of outlook to be installed rather than 1. Now I need the
utility to work for all 3 versions. A previous post suggested
creating objects to detect the version of outlook, which I tried with
success. But, that's as far as I can get. No one out there shows how
to go beyond version detection to actually creating, deleting and
modifying outlook contacts, emails, and appointments. I tried creating
the extra outlook objects I need (shown bellow). So far, VB doesn't
show any errors during programming. When ran, I get an activex error:
"Cannot create Axtivex Component".

Code:
'open outlook application
Private objOutlook As Object = CreateObject("Outlook.Application")

'store outlook session
Private objNS As Object = CreateObject("Outlook.NameSpace")
'outlook folder variable
Private objFolder As Object = CreateObject("Outlook.MAPIFolder")
'outlook items variable
Private objItems As Object = CreateObject("Outlook.Items")
'outlook contact variable
Private objContact As Object = CreateObject("Outlook.ContactItem")
Private objNS As Object = CreateObject("Outlook.NameSpace") =
objOutlook.Session
doesn't create the activex component. Keep in mind, the utility works
great if I reference a specific version interop assembly. I have been
searching for the past few days without success. Has anyone else had
any success?

Thank you.

Dec 29 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
wizzbangca,
I would recommend upgrading every one to Outlook 2003, which would allow
creating a VSTO 2.0 addin for Outlook. VSTO 2.0 greatly simplifies create
Outlook add-ins in .NET!

If upgrading is not an option, then the "easiest" way is to write your
add-in to the lowest common denominator. Write the add-in to Outlook 2000,
reference Outlook 2000 type library, compile & develop against that.
Alternatively don't reference a type library & use late binding (Object
variables).

| Private objOutlook As Object = CreateObject("Outlook.Application")
Should work as Outlook.Application is a creatable object.
| 'store outlook session
| Private objNS As Object = CreateObject("Outlook.NameSpace")
Will fail as Outlook.Namespace is NOT a creatable object, you use
objOutlook.GetNamespace to get the namespace object.

| Private objOutlook As Object = CreateObject("Outlook.Application")
| Private objNS As Object = objOutlook.GetNamespace("MAPI")
Normally what I do when using Late binding & Outlook (VBScript for example)
is to write a macro in the VBIDE in Outlook (Alt+F11 when the Outlook
Explorer window is open) for intellisense. Then change all the strongly
typed variables to Object. You could probably adopt a similar method for
late binding in VB.NET...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"wizzbangca" <wi********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
| Hi everyone. Having problems with a utility I am writing for work.
| The previous IT Director thoughtfully allowed 3 (2000, xp, 2003)
| versions of outlook to be installed rather than 1. Now I need the
| utility to work for all 3 versions. A previous post suggested
| creating objects to detect the version of outlook, which I tried with
| success. But, that's as far as I can get. No one out there shows how
| to go beyond version detection to actually creating, deleting and
| modifying outlook contacts, emails, and appointments. I tried creating
| the extra outlook objects I need (shown bellow). So far, VB doesn't
| show any errors during programming. When ran, I get an activex error:
| "Cannot create Axtivex Component".
|
| Code:
| 'open outlook application
| Private objOutlook As Object = CreateObject("Outlook.Application")
|
| 'store outlook session
| Private objNS As Object = CreateObject("Outlook.NameSpace")
| 'outlook folder variable
| Private objFolder As Object = CreateObject("Outlook.MAPIFolder")
| 'outlook items variable
| Private objItems As Object = CreateObject("Outlook.Items")
| 'outlook contact variable
| Private objContact As Object = CreateObject("Outlook.ContactItem")
|
|
| Private objNS As Object = CreateObject("Outlook.NameSpace") =
| objOutlook.Session
| doesn't create the activex component. Keep in mind, the utility works
| great if I reference a specific version interop assembly. I have been
| searching for the past few days without success. Has anyone else had
| any success?
|
| Thank you.
|
Jan 3 '06 #2

P: n/a
objOutlook.GetNamespace
Doesn't work - "Parameter not optional" error.

Jan 12 '06 #3

P: n/a
wizzbangca,
Did you try passing the "MAPI" parameter as I showed:

| Private objOutlook As Object = CreateObject("Outlook.Application")
| Private objNS As Object = objOutlook.GetNamespace("MAPI")
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"wizzbangca" <wi********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
| objOutlook.GetNamespace
| Doesn't work - "Parameter not optional" error.
|
Jan 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.