PDA

View Full Version : Help changing code from cdonts to cdosys?


t3cat5
09-01-2009, 02:17 PM
working with "DUclassifieds" ad script and need help changing the form mailer of details page to use cdosys from cdonts. here is the code i wish to change if anyone can help?


-->

<%
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = Request.Form("EMAIL")
objCDO.To = Request.Form("POSTER_EMAIL")
objCDO.cc = Request.Form("EMAIL")
objCDO.Subject = Request.Form("SUBJECT")
objCDO.Body = Request.Form("MESSAGE")
objCDO.Send()
Set objCDO = Nothing
%>

-->

the config file looks like this if it matters..

<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
MM_connDUclassified_STRING = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\my\wwwroot\webfolder\database\databank.mdb"
%>

Old Pedant
09-01-2009, 10:06 PM
Ummm...that config is *STRICTLY* for the database connection. It's a crappy database connection, using the Access Driver instead of OLEDB (much less reliable, much more sensitive to problems), but it *is* strictly for the DB.

Anyway, ignoring that...

The exact form needed for CDO varies from system to system. *MOST* systems can use the simplest form, which is as follows:

<%
CONST sendUrl = "http://schemas.microsoft.com/cdo/configuration/sendusing"
CONST smtpUrl = "http://schemas.microsoft.com/cdo/configuration/smtpserver"

' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
objConfig.Fields.Item(smtpUrl)="...need the path to your SMTP server here..."
objConfig.Fields.Update

' Create and send the mail
Set objMail=CreateObject("CDO.Message")
' Use the config object created above
Set objMail.Configuration=objConfig

objCDO.From = Request.Form("EMAIL")
objCDO.To = Request.Form("POSTER_EMAIL")
objCDO.cc = Request.Form("EMAIL")
objCDO.Subject = Request.Form("SUBJECT")
objCDO.Body = Request.Form("MESSAGE")
objCDO.Send()

objMail.From = ...
objMail.To = ...
objMail.Cc = ...
objMail.Subject = ...
objMail.TextBody = ... ' ONLY USE if body is *NOT* HTML!
objMai.HTMLBody = ... ' use this if the body *IS* HTML
result = objMail.Send
If result = "" Then result = "Success!"
Response.Write "Email sent to " & EMail & ", result: " & result & "<br>" & vbNewLine

Set objMail = Nothing
%>

You can see that, except for the need of the Configuration information and the choice of HTMLBody or TextBody, it's pretty much the same.

t3cat5
09-02-2009, 02:29 AM
thanks for the help will see how it works out as for the config I plan to add to it quite a bit just in the dev.. stage at the moment as for the OLEDB bit if you can help with the script to use that would be very helpful. thanks again m8

Old Pedant
09-02-2009, 07:49 PM
Sure...sorry...

Try this.

<%
MM_connDUclassified_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\my\wwwroot\webfolder\database\databank.mdb"
%>

But usually you should use a *relative* path to your database, so that when you upload it from the development machine to the production machine you don't have to change the code. So usually something like:

<%
MM_connDUclassified_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.MapPath("./database/databank.mdb")
%>

with the actual relative path depending on how you have organized the site.