|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET & Various Versions Of OutlookThe 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. 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 Will fail as Outlook.Namespace is NOT a creatable object, you use | Private objNS As Object = CreateObject("Outlook.NameSpace") objOutlook.GetNamespace to get the namespace object. | Private objOutlook As Object = CreateObject("Outlook.Application") Normally what I do when using Late binding & Outlook (VBScript for example) | Private objNS As Object = objOutlook.GetNamespace("MAPI") 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... -- Show quoteHide quoteHope this helps Jay [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "wizzbangca" <wizzban***@yahoo.com> wrote in message news:1135823366.958783.281170@g14g2000cwa.googlegroups.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. | objOutlook.GetNamespace
Doesn't work - "Parameter not optional" error. wizzbangca,
Did you try passing the "MAPI" parameter as I showed: Show quoteHide quote | Private objOutlook As Object = CreateObject("Outlook.Application") | Private objNS As Object = objOutlook.GetNamespace("MAPI") -- Show quoteHide quoteHope this helps Jay [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "wizzbangca" <wizzban***@yahoo.com> wrote in message news:1137108989.605905.116940@g14g2000cwa.googlegroups.com... | objOutlook.GetNamespace | Doesn't work - "Parameter not optional" error. |
control arrays
Setting MaxLength to <VBFixedString(x)>? howto make a console app start with window minimized How can you add a custom user control to a datagridview? GDI Question User Control and Namespace question Pointer in a structure To use ShellExecute or not? Retrieving a webpage source HTM and checking for a string thereinL? Export from VB.NET 2003 to an Excel spreadsheet |
|||||||||||||||||||||||