Outlook 2007 MAPI Replacement for VB6

A

ataylorm

Good Morning,



I have a classic ASP page on an internal website that uses a VB6 DLL which
is downloaded to the client computer and access the MAPI components to select
contacts from their address book.



In other words I have a ASP page that sends a mass e-mail inside the company
and the user clicks a button which displays their outlook contact list, where
they select a distribution list, and that is returned to the page, which then
sends the e-mail.



The problem I have is that with Outlook 2007, MAPI isn't installed. We have
tens of thousands of PCs in three thousand locations around the world, and I
don't have the ability to control how they install Office 2007. That means I
need to find a way to make the DLL compatible until the site can be rewritten
next year.



My approach to this was to change the DLL to first try and use MAPI for
those still on outlook 2003, then if mapi couldn't be created, use the new
SelectNamesDialog to get the addresses from Outlook 2007. The problem is
that I can not get the SelectNamesDialog to work at all in VB6. I do have
the reference set for the Outlook 12 object. Here is the code I have, I am
getting error 287 application error:



Dim OutApp As New Outlook.Application
Dim oDialog As Outlook.SelectNamesDialog
Dim oAL As Outlook.AddressList
Dim oContacts As Outlook.Folder

Set oDialog = Outlook.Session.GetSelectNamesDialog
Set oContacts = OutApp.Session.GetDefaultFolder(olFolderContacts)


The Set oDialog = Outlook.Session.GetSelectNamesDialog is the line giving
me the trouble. I pulled this code from
http://msdn2.microsoft.com/en-us/library/bb176400.aspx



Any help with this would be VERY appreciated, I have been working on this
for nearly two weeks, and my boss is getting irritated.
 
E

Eric Legault [MVP - Outlook]

I think your issue is that you have early-bound references to the Outlook
2007 Object Model, and this will fail when run on machines using an earlier
version of Outlook. Declare oDialog as Object, and retrieve it from another
generic Object variable that you'd set to the Outlook.NameSpace object.

e.g.

Dim oDialog As Object
Dim objNS As Object

If Left(OutApp.Version, 2) = "12" Then
Set objNS = OutApp.GetNameSpace("MAPI")
Set oDialog = objNS.SessionGetSelectNamesDialog
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top