PDA

View Full Version : How to Change CDONTS with CDOSYS


nk2join
10-08-2005, 08:46 PM
Hy gusy
I have the following Email scripts I want to change it to CDOSYS Pls reply if some on know
Thank



<%
Response.Buffer = True


Dim strBody mail
Dim objCDOMail
Dim strCCEmailAddress
Dim strBCCEmailAddress
Dim strReturnEmailAddress

strMyEmailAddress = "mymail@mysite.com"
strCCEmailAddress = "mymail1@mysite.com"
strBCCEmailAddress = ""
strReturnEmailAddress = Request.Form("email")

strBody = "<h2>Feedback </h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><b>Name: </b>" & Request.Form("location")
strBody = strBody & "<br><b>Name: </b>" & Request.Form("subject")
strBody = strBody & "<br><br><b>Message: - </b><br>" & Replace(Request.Form("msg"), vbCrLf, "<br>")


If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1, strReturnEmailAddress, "@", 1) Then

'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If


Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

objCDOMail.From = Request.Form("firstName")
objCDOMail.To = strMyEmailAddress
objCDOMail.Cc = strCCEmailAddress
objCDOMail.Bcc = strBCCEmailAddress
objCDOMail.BodyFormat = 0
'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
'Set the subject of the e-mail
objCDOMail.Subject = "Feedback"
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
objCDOMail.Send
Set objCDOMail = Nothing
%>

Bullschmidt
10-13-2005, 05:52 AM
Yes CDO is generally used instead of CDONTS on IIS 5 and after (actually the SMTP service within IIS) which is generally on servers after Win NT4 (although I think CDONTS is sometimes still supported too).

Here's a quickie memo to myself about converting my old CDONTS code to CDO:

o Change objCDONTS to be called objCDO (actually this is just a cosmetic change)

o This:
Set objCDONTS = Server.CreateObject("CDONTS.NewMail")

Changed to this instead:
Set objCDO = Server.CreateObject("CDO.Message")

o This:
objCDONTS.Body = strEmailBody

Changed to this instead:
objCDO.TextBody = strEmailBody

o This removed:
' Importance.
' (0=Low, 1=Normal, 2=High)
objCDONTS.Importance = 1

And here's a nice CDO link even if you don't use the attachment part:
Email (with Attachment)
http://www.asp101.com/samples/email_attach.asp