Solved

Converting from CDONTS to CDOSYS

Posted on 2013-12-16
6
235 Views
Last Modified: 2014-03-01
I have been asked to look at a piece of code which no longer works on a website.  The code generates an email and sends it.  I think the problem is that the site is now on IIS7 which doesnt support CDONTS but I have no idea what im doing trying to convert it.  Ive tried using the godaddy support Godaddy Support but that didnt help.

So the original asp file (sendmail.asp) had (Ive changed the From address for security):-

<script language="javascript" runat="server" src="opendatabase.js"></script>
<script language="javascript" runat="server" src="paramtest.js"></script>
<script language="javascript" runat="server" src="debug.js"></script>
<script language="javascript" runat="server" src="MD5.js"></script>
<script language="javascript" runat="server" src="testlogin.js"></script>

<script language="Javascript" runat="server">

var fromEmail = "admin@testserver.co.uk";

function SendMIMEEMail(toadd,fromadd,subject,body) {
	var objCDO;
	
	try {
		objCDO = Server.CreateObject("CDONTS.NewMail");
	
		objCDO.To		= toadd;
		objCDO.From		= fromadd;
		objCDO.Subject		= subject;
		objCDO.Body		= body;
		objCDO.MailFormat	= 0; //CdoMailFormatMime;
		objCDO.BodyFormat	= 0; //CdoBodyFormatHTML;
		objCDO.Send();
	
		Response.write("{'status':'success'}");
	} catch(e) {
		Response.write("{'status':'error sending email: " + e.description'}");
	}
}

function main() {

	var dbConn,dbRec,SQL;
	
	dbConn = OpenDatabase();
	dbConn.Close();
	
}

</script>

Open in new window


I thought I could do the following but it just shows errors on page when I run it.

<script language="javascript" runat="server" src="opendatabase.js"></script>
<script language="javascript" runat="server" src="paramtest.js"></script>
<script language="javascript" runat="server" src="debug.js"></script>
<script language="javascript" runat="server" src="MD5.js"></script>
<script language="javascript" runat="server" src="testlogin.js"></script>

<script language="Javascript" runat="server">

var fromEmail = "admin@testserver.co.uk";

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

set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendurl)=2
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
objConfig.Fields.Update

function SendMIMEEMail(toadd,fromadd,subject,body) {
	var objCDO;
	
	try {
		objCDO = Server.CreateObject("CDO.Message");
	
		objCDO.To		= toadd;
		objCDO.From		= fromadd;
		objCDO.Subject		= subject;
		objCDO.Body		= body;
		objCDO.MailFormat	= 0; //CdoMailFormatMime;
		objCDO.BodyFormat	= 0; //CdoBodyFormatHTML;
		objCDO.Send();
	
		Response.write("{'status':'success'}");
	} catch(e) {
		Response.write("{'status':'error sending email: " + e.description'}");
	}
}

function main() {

	var dbConn,dbRec,SQL;
	
	dbConn = OpenDatabase();
	dbConn.Close();
	
}

</script>

Open in new window


Where am I going wrong?

Thanks
0
Comment
Question by:simonwait
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39722884
The code in the Godaddy article works just fine on a page by itself.  I have it running on several sites.  It could be that the "CDO.Configuration" is not accessible inside that function.

This page http://www.w3schools.com/asp/asp_send_email.asp shows a number of variations for different situations.
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39723185
Note: Below is vbscript, not jscript

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = subject 
objMessage.From = fromadd 
objMessage.To = toadd
objMessage.htmlBody = body

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"

'Server port (typically 25) 
'** check your godaddy specs for this
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39723400
Oops, I missed that.  The code from Godaddy is Definitely ASP VBscript.  Javascript in the browser can not send email.  This page shows that you can do Jscript on the server but it has to be in ASP blocks <% %>, not <script> tags.
0
 
LVL 1

Author Comment

by:simonwait
ID: 39726659
Thanks for your help.   My ftp¿login for the site isn't working so im not ignoring the help just can't test at the moment
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39896986
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question