Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Emailing from VFP CDONTS
Message
From
04/10/2006 12:21:16
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01159359
Message ID:
01159413
Views:
21
Is cdonts installed? Is IIS installed?

http://www.webthang.co.uk/Tuts/tuts_server/smtp1/smtp1_1.asp

>Hi All,
>i've code samples from Craig Boyd's website but i'am getting "Class Defination CDONTS.NEWMAIL is not found" error
>my mail server support CDONTS mail system where is the wrong ?
>
>TIA
>
>
>*******************************
>*!* Example of using SendViaCDONTS
>*******************************
>#DEFINE CDOLOW  0
>#DEFINE CDONORMAL  1
>#DEFINE CDOHIGH  2
>
>DIMENSION aryAttach(1)
>aryAttach(1) = "C:\scancode.txt" && change to an actual file that exists on your computer
>*aryAttach(2) = "C:\attachment2.zip" && change to an actual file that exists on your computer
>
>LOCAL lcFrom, lcTo, lcSubject, lcBody, lcCC, lcBCC, llHTMLFormat, lcErrReturn
>
>lcFrom = "soykan@soykansoft.com"
>lcTo = "soykan@soykansoft.com"
>lcSubject = "Hey Have You Tried VFP Email?"
>*!* Sending the body in HTML format
>llHTMLFormat = .T. && change to .F. to send plain text message
>lcBody = "<a href='http://www.sweetpotatosoftware.com/SPSBlog/default.aspx'>" + ;
> "Hey Have You Tried VFP Email?" + ;
> "</a>"
>lcCC = "soykan@soykansoft.com"
>lcBCC = "soykan@soykansoft.com"
>
>SendViaCDONTS(@lcErrReturn, lcFrom, lcTo, lcSubject, lcBody, @aryAttach, lcCC, lcBCC, llHTMLFormat, CDOHIGH)
>
>IF EMPTY(lcErrReturn)
> MESSAGEBOX("'" + lcSubject + "' sent successfullly.", 64, "Send email via CDO NTS")
>ELSE
> MESSAGEBOX("'" + lcSubject + "' failed to be sent.  Reason:" + CHR(13) + lcErrReturn, 64, "Send email via CDO NTS")
>ENDIF
>
>*******************************************
>PROCEDURE SendViaCDONTS(tcReturn, tcFrom, tcTo, tcSubject, tcBody, taFiles, tcCC, tcBCC, tlHTMLFormat, tnImportance)
>*******************************************
> #DEFINE CDOMAILFORMATMIME  0
> #DEFINE CDOMAILFORMATTEXT  1
>
> #DEFINE CDOBODYFORMATHTML  0
> #DEFINE CDOBODYFORMATTEXT  1
>
> LOCAL loNewMail, lnCountAttachments
> TRY
>  loNewMail = CREATEOBJECT("CDONTS.NewMail")
>  WITH loNewMail
>   .FROM = tcFrom
>   .TO = tcTo
>   IF TYPE("tcCC") = "C"
>    .CC = tcCC
>   ENDIF
>   IF TYPE("tcBCC") = "C"
>    .BCC = tcBCC
>   ENDIF
>   IF tlHTMLFormat
>    .MailFormat = CDOMAILFORMATMIME
>    .BodyFormat = CDOBODYFORMATHTML
>   ELSE && these are default so not necessary, included for info purposes
>    .MailFormat = CDOMAILFORMATTEXT
>    .BodyFormat = CDOBODYFORMATTEXT
>   ENDIF
>   IF TYPE("tnImportance") = "N"
>    .Importance = tnImportance
>   ELSE
>    .Importance = 1 && Normal
>   ENDIF
>   .Subject = tcSubject
>   .Body = tcBody
>   IF TYPE("taFiles", 1) = "A"
>    FOR lnCountAttachments = 1 TO ALEN(taFiles)
>     .AttachFile = taFiles(lnCountAttachments)
>    ENDFOR
>   ENDIF
>   .SEND()
>  ENDWITH
>
> CATCH TO loError
>  tcReturn = [Error: ] + STR(loError.ERRORNO) + CHR(13) + ;
>   [LineNo: ] + STR(loError.LINENO) + CHR(13) + ;
>   [Message: ] + loError.MESSAGE + CHR(13) + ;
>   [Procedure: ] + loError.PROCEDURE + CHR(13) + ;
>   [Details: ] + loError.DETAILS + CHR(13) + ;
>   [StackLevel: ] + STR(loError.STACKLEVEL) + CHR(13) + ;
>   [LineContents: ] + loError.LINECONTENTS
> FINALLY
>  RELEASE loNewMail
>  loNewMail = .NULL.
> ENDTRY
>ENDPROC
>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform