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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO mail function help

Status
Not open for further replies.

FoxT2

MIS
Oct 3, 2003
143
US
Hi,

Ok here is the situation. I have MS Exchange 2003 (Version: 6.5.7638.1) on a MS Windows 2003 server. All clients have WinXP Pro with MS outlook installed. I'm trying to develop an application that can send emails without using MS Outlook. So I am trying the CDO mail funcion (cdosys.dll). I have tried using the code from faq1251-4969 (How to send e-mail using CDO and checking the connection status first. By Mike Gagnon) and tried using code like this..

oMSG = CREATEOBJECT('cdo.message')
oMSG.To = 'me@mydomain.com'
oMSG.From = 'you@mydomain.com'
oMSG.Subject = 'Hello Email'
oMSG.TextBody = 'This is an easy way to create an email'
oMSG.Send()

Still not 1 email is being sent. I have read through other posts about CDO mail problems and most replys say to be sure you have CDO installed on the client computer. I believe I have it installed, but could someone PLEASE explain how to install this so I can be sure I did it right. Unless I'm missing something here, it sounds to me like all you need to do is have the cdosys.dll registered on the client machine. But appearently there must be more to it than that. I have read the MS support article "Where to acquire the CDO Libraries (all versions)"


but this does not help much for setting this up on a client computer. Other than saying to register the .dll file with regsrv32.exe.


Please Help,

FoxT
 
How can I send an Email using OUTLOOK from VFP? faq184-766

How to send e-mail Automating CDO faq184-1768

How to send e-mail using MAPI session faq184-1769

How to send email using SMTP and no third party OCX? faq184-3840

Quick and easy way to send attachements using the default e-mail
 
Take a look at faq184-1768 at the beginning of the FAQ it says:
There reason CDO2.0 avoids the security patch of Outlook is, it does not require Outlook to work. (Thank you Jonscott8 for this clarification)
Note #1 : This requires SMTP services installed and running on the local computer.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Make sure you do not have a cdoex.dll file in use. I have run into problems like this when the cdoex.dll file is registered. The cdoex.dll supersedes the cdosys.dll file for some reason. So anyone having problems getting the cdosys.dll to register it could be because you have the cdoex.dll file registered. I solved the problem by unregistering the cdoex.dll file, then registering the cdosys.dll file. I found the solution here.


Razzle
 
Try:

* Define your mail server name here
#DEFINE D_MailServerName "mail.example.com"
LOCAL lcTo, lcFrom, lcSubject, lcTextBody, lcHTMLBody
lcTo = "ravi@example.com"
lcFrom = "ravi@example.com"
lcSubject = "CDO Mail"
lcTextBody = "Sample message sent using CDO Mail."
IF cdoMail(lcTo, lcFrom, lcSubject, lcTextBody) = .F.
WAIT WINDOW "Could not send message using CDO." NOWAIT
ELSE
WAIT WINDOW "Message sent successfully." NOWAIT
ENDIF

FUNCTION CDOMail
* Sends mail using CDO. Returns .T. if successful
LPARAMETERS tcTo, tcFrom, tcSubject, tcTextBody, tcHTMLBody
LOCAL loMsg, liConfig, loFields, llOK
loMsg = Createobject("CDO.Message")
IF VARTYPE(loMsg) = "O" && Object
liConfig = Createobject("CDO.Configuration")
IF VARTYPE(liConfig) = "O"
loFields = liConfig.Fields
WITH loFields
.Item(" = 2
.Item(" = D_MailServerName
.Item(" = 25
.Item(" = 90
.Update
ENDWITH
* Define message properties
WITH loMsg
.Configuration = liConfig
.To = tcTo
.From = tcFrom
.Subject = tcSubject
* Use HTML Body text, if provided, otherwise use Text body
IF ! EMPTY(tcHTMLBody)
.HTMLBody = tcHTMLBody
ELSE
.TextBody = tcTextBody
ENDIF
.Send
llOK = .T.
ENDWITH
ENDIF
ENDIF
RETURN llOK
ENDFUNC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top