Cannot Create MAPI.Session object when ...

T

Tagman

After I do the following action:
gCdoSession = CreateObject("MAPI.Session")
I got the following popup box.

"Either there is no default mail client or the current mail client
cannot fulfill the messaging request. Please run Microsoft Outlook and
set it as the default mail client."

And gCdoSession.logon will fail because gCdoSession is nothing.

When the user's default mail client is not Outlook and create
MAPI.Session object, that popup message will come and cannot use
MAPI.Session. It forces me to use Outlook object, however, its speed is
very slow, especially, I got so many contact(located in local hard disk,
nothing related to exchange) I need to process. Any solution on it?

is there any profile for local outlook without any exchange server?

Does anyone have some sample code to find the profile and login to that
profile?

Because I tried this:
gCdoSession.Logon("Microsoft Outlook Internet Settings", "", False, True, 0)

because I found the DefaultProfile from the registry:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles

is "Microsoft Outlook Internet Settings", therefore, I try to do the
logon to the profile with same name. Of course I cannot, because the
gCdoSession is nothing.

Regards,
Tony
 
K

Ken Slovak - [MVP - Outlook]

Is this a Basic type language? Is this CDO 1.21? Is Outlook running at the
time?

Set gCdoSession = CreateObject("MAPI.Session")
gCdoSession.Logon "", "", False, False

If Outlook is running use a piggy-back logon as shown. If not then see the
code samples at www.cdolive.com/cdo5.htm for different CDO 1.21 logon
methods.

CDO 1.21 is an optional installation for Outlook 2000 and later. Make sure
it's installed.
 
T

Tagman

I have checked that my CDO version is 1.21 already. Whenever I issue
the call gCdoSession = CreateObject("MAPI.Session"), I got the same
message asking me to set outlook as default mail client. and the
gCdoSession remains Nothing.

Regards,
Tony
 
K

Ken Slovak - [MVP - Outlook]

So set Outlook as your default mail client in the Programs tab of IE
settings.
 
K

Ken Slovak - [MVP - Outlook]

I'm sure it's a registry setting somewhere, where I'm not sure offhand. You
could see if you can find the location with google or you can run a monitor
such as RegMon to see what gets changed when you change the default email
program in the IE settings. I'm sure it would have to be done before Outlook
starts up however, it couldn't be done on the fly while Outlook was running.
 

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