Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAPI.Session Fail on 2000 1

Status
Not open for further replies.

Nro

Programmer
May 15, 2001
337
CA
Hi all

I've start one VFP 9.0 program to read Mail from CDO.

Here is my code ;

lobjSession = CreateObject("MAPI.Session")
lobjSession.Logon("outlookExchange")
lobjSession = NULL

On my PC (Win XP Home), and my server (Win 2000 Server), it work fine. But on my customer station, I've received this message ;


Class definintion MAPI.SESSION is not found


I've search Microsoft KB and there is an article about this message. The only solution seem to register cdoNts.dll (RegSvr32 c:\WINNT\system32\cdonts.dll). I've try that, but nothing works.

The customer machine is : Win 2000 Pro, with Outlook 2000 installed. All the updates and SP are installed. I'm working with VFP 9.0.

Thanks in advance.

Nro
 
In my experience CDONTS.DLL is for use with Windows NT and CDO.dll is for Windows 2000. But if you get this going you may encouter a pop-up mesaage that is wanrning the user that someone is trying to send an e-mail. You may consider upgrading to CDOSYS.DLL (CDO 2.0) which will not use MAPI as a transport engine, and avoiding this annoying security message.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks for the quick reply Mike.

The link you gave is exactily the one I found when I search the MS KB. It has no effect.

But I made some more research and found something that said the CDO is installed with Office SP2. My customer has no SP installed at all. So I'll try to patch it later.

When you said "upgrading to CDOSYS.DLL (CDO 2.0)" I suppose I have to install some software on my customer machine?

Thanks
 
Nro.

When you said "upgrading to CDOSYS.DLL (CDO 2.0)" I suppose I have to install some software on my customer machine?

If you upgrade you client to SP2, I have a feeling you are about to install CDO2.0 (They should have named them differently since CDO1.x and CDO2.0 do not function the same way nor is the coding the same)
CDO2.0 requires an SMTP service or an SMTP server to work and you will find some coding samples in faq1251-4969 and also in faq184-1768, you also find coding samples of CDO1.X in faq184-1769.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Salut Mike (again).

I'm sorry but my knowledge of e-mailing is very limited. So, I appreciate your help.

Now, I test the code you gave me (FAQ1251-4969) and I received no error from the customer machine. I know the Exchange server name, and I'm pretty sure that's an SMTP protocol.

The program worked, it seem to send the message. I send it to a known address, but, if I open Outlook (on the client machine), there is no message in the outbox (it's normal, it use Exchange).

I'll have to do more testing to verify if it has be send correctly.

PS : I installed the latest patch for Outlook and I've received the same message. The version of CDOSYS.DLL is 6.1.3940


Thanks

Nro
 
The program worked, it seem to send the message. I send it to a known address, but, if I open Outlook (on the client machine), there is no message in the outbox (it's normal, it use Exchange).

CDO is its own entity, nothing to do with Outlook. In other word it will not keep a copy of the e-mail message that was sent (the quick fix is to BCC the message) . It is a tool to send an e-mail message, not keeping a copy, nor display capability etc...All these other features are feasable, but requires other modules to be programmed.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I'm back to my office and I received the message sent from my client place. So I think I'm on the right way.

A star for you Mike. I think you save me a lot of time with your ressources and professional advises, so you deserve it.

Nro



 
So, if I understand right, MAPI.Session and CDO.Message use the same object model (or an equivalent). I'm asking that because I was not able to fix the subject of my first question : CreateObject("MAPI.Session") still fails on my clients machine.

If I'm not able to use MAPI, is CDO equivalent ?

Thanks

Nro
 
So, if I understand right, MAPI.Session and CDO.Message use the same object model (or an equivalent). I'm asking that because I was not able to fix the subject of my first question : CreateObject("MAPI.Session") still fails on my clients machine.

Here is a quote from MSDN that explains the differences. I realize it does not explain why it failed on your client's machine, but it could be many factors and hard to determine sometimes.



MSDN said:
CDO for Windows 2000
CDO for Windows 2000, sometimes referred to as CD0 2.0 or CDOSYS.DLL, is designed to provide an object model for the development of messaging applications on Windows 2000. CDOSYS is based on the Simple Mail Transfer Protocol (SMTP) and Network News Transfer Protocol (NNTP) standards and is available as a system component on Microsoft Windows 2000 Server installations. It is the standard API for building bulk-mailing/Web-based messaging applications on Windows 2000 Server.

CDOSYS is not an update to the CDO 1.2.1 model in terms of new objects or the underlying architecture. Think of CDOSYS as providing enhanced functionality over the existing CDO for Windows NT Server (CDONTS) library, which is available via Windows NT 4.0 Option Pack 1. Although CDOSYS provides the same functionality as CDONTS (plus some additional features), the two are not code-compatible. CDOSYS was written from the ground up to directly manipulate Internet content and is not code-compatible with previous versions of CDO based on MAPI, including CDO 1.1, 1.2, and 1.2.1.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 

You also may want to try running this code to determine what is (or is not) installed on your clients machine. The OleMessaging with a value of 1 would indicate that CDO is installed on your client's computer. The Mapi refer to MAPI and Simple MAPI.

Code:
#Define ERROR_SUCCESS               0
#Define KEY_READ               131097
#Define KEY_ALL_ACCESS         983103
#Define HKEY_LOCAL_MACHINE     2147483650 && 0x80000002
Declare Integer RegCloseKey In advapi32 Integer hKey
Declare Integer RegOpenKeyEx In advapi32;
           INTEGER   hKey,;
           STRING    lpSubKey,;
           INTEGER   ulOptions,;
           INTEGER   samDesired,;
           INTEGER @ phkResult

Declare Integer RegEnumValue In advapi32;
           INTEGER   hKey,;
           INTEGER   dwIndex,;
           STRING  @ lpValueName,;
           INTEGER @ lpcValueName,;
           INTEGER   lpReserved,;
           INTEGER @ lpType,;
           STRING  @ lpData,;
           INTEGER @ lpcbData

hBaseKey = 0
lcBaseKey = "Software\Microsoft\Windows Messaging Subsystem"
If RegOpenKeyEx (HKEY_LOCAL_MACHINE, lcBaseKey,;
                       0, KEY_ALL_ACCESS, @hBaseKey) <> ERROR_SUCCESS
           ? "Error opening registry key"
Return
Endif
Create Cursor cs (valuename C(50), valuevalue C(200))
dwIndex = 0
Do While .T.
                       lnValueLen = 250
            lcValueName = Repli(Chr(0), lnValueLen)
                       lnType = 0
            lnDataLen = 250
                       lcData = Repli(Chr(0), lnDataLen)
            lnResult = RegEnumValue (hBaseKey, dwIndex,;
                       @lcValueName, @lnValueLen, 0,;
                       @lnType, @lcData, @lnDataLen)
                       If lnResult <> ERROR_SUCCESS
                      Exit
           Endif
           lcValueName = Left (lcValueName, lnValueLen)
           lcData = Left (lcData, lnDataLen-1)
           Insert Into cs Values (lcValueName, lcData)
           dwIndex = dwIndex + 1
Enddo

=RegCloseKey (hBaseKey)

Select cs

Index On valuename Tag valuename

Go Top

Browse Normal Nowait

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Salut Mike.

I've read some more articles for MAPI and CDO on MSDN and cdoLive (very helpfull site).

Now I'll have to test the components of the customer machine with the code you gave me. So far, the result are the same. I'm surprised that a very simple command (createObject("MAPI.SESSION")), that is working on all my testing machines (even with one with no Outlook installed), refuse to work on my client box.

Thanks again.

Nro
 
Finally.

I reintall Office 2000 (with everything running on disk) and now, no more MAPI.SESSION fail message.

I suspect an Office service pack or patch to be responsible for these problem.

Regards

Nro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top