Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Converting from CDONTS to CDOSYS

Posted on 2013-12-16
6
Medium Priority
?
237 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 84

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 2000 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 84

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

688 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