Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with cdonts

Status
Not open for further replies.

rnowrang

IS-IT--Management
May 6, 2004
27
US
I am trying to use the same form to add data to a data base and send an email using cdonts. I am successfully sending the info to the database but am not able to send to email. Can someone please help me? Thank you.
 
Please post your code and list any errors that you are getting.

-VJ
 
there are no errors. but no mail is getting sent. below is the code:

Thanks.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ncf_conn.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_ncf_conn_STRING
MM_editTable = "prayer"
MM_editRedirectUrl = "prayer_box.asp"
MM_fieldsStr = "name|value|email|value|subject|value|request|value"
MM_columnsStr = "FirstName|',none,''|EmailAddress|',none,''|Subject|',none,''|Request|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim PrayerRS
Dim PrayerRS_numRows

Set PrayerRS = Server.CreateObject("ADODB.Recordset")
PrayerRS.ActiveConnection = MM_ncf_conn_STRING
PrayerRS.Source = "SELECT * FROM prayer ORDER BY Date ASC"
PrayerRS.CursorType = 0
PrayerRS.CursorLocation = 2
PrayerRS.LockType = 1
PrayerRS.Open()

PrayerRS_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>New Community Fellowship: Prayer request</title>
<link href="backgrounds.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #660000;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>

<body onLoad="MM_preloadImages('Images/nav_contactus_on.gif','Images/nav_worship_on.gif','Images/nav_ministries_on.gif','Images/nav_calender_on.gif','Images/nav_aboutus_on.gif','Images/nav_news_on.gif','Images/nav_downloads_on.gif','Images/nav_prayer_request_on.gif','Images/inthespotlight_on.gif','Images/nav_prayer_box_on.gif')">
<table width="720" border="0" cellspacing="0" cellpadding="0" summary="Navigation">
<tr>
<td colspan="5" align="left" valign="top"><a href="index.htm"><img src="Images/NCF_logo.gif" name="logo" width="600" height="67" border="0" id="logo"></a></td>
<td align="left" valign="baseline"><a href="contact_us.asp" onMouseOver="MM_swapImage('contactus','','Images/nav_contactus_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/nav_contactus.gif" name="contactus" width="120" height="17" border="0" id="contactus"></a></td>
</tr>
<tr>
<td colspan="6"><img src="Images/placeholder.gif" width="720" height="1"></td>
</tr>
<tr>
<td><script language="JavaScript1.2">mmLoadMenus();</script>
<a href="javascript:;" onMouseOut="MM_swapImgRestore();MM_startTimeout()" onMouseOver="MM_showMenu(window.mm_menu_0406023439_0,0,17,null,'nav_worship');MM_swapImage('nav_worship','','Images/nav_worship_on.gif',1);"><img name="nav_worship" src="Images/nav_worship.gif" width="120" height="17" border="0" alt=""></a></td>
<td><a href="javascript:;" onMouseOver="MM_swapImage('navministries','','Images/nav_ministries_on.gif',1);MM_showMenu(window.mm_menu_0406024602_0,0,17,null,'navministries')" onMouseOut="MM_swapImgRestore();MM_startTimeout()"><img src="Images/nav_ministries.gif" name="navministries" width="120" height="17" border="0" id="navministries"></a></td>
<td><a href="javascript:;" onMouseOver="MM_swapImage('calendar','','Images/nav_calender_on.gif',1);MM_showMenu(window.mm_menu_0406025028_0,0,17,null,'calendar')" onMouseOut="MM_swapImgRestore();MM_startTimeout()"><img src="Images/nav_calender.gif" name="calendar" width="120" height="17" border="0" id="calendar"></a></td>
<td><a href="javascript:;" onMouseOver="MM_swapImage('aboutus','','Images/nav_aboutus_on.gif',1);MM_showMenu(window.mm_menu_0406025251_0,0,17,null,'aboutus')" onMouseOut="MM_swapImgRestore();MM_startTimeout()"><img src="Images/nav_aboutus.gif" name="aboutus" width="120" height="17" border="0" id="aboutus"></a></td>
<td><a href="javascript:;" onMouseOver="MM_swapImage('news','','Images/nav_news_on.gif',1);MM_showMenu(window.mm_menu_0406025445_0,0,17,null,'news')" onMouseOut="MM_swapImgRestore();MM_startTimeout()"><img src="Images/nav_news.gif" name="news" width="120" height="17" border="0" id="news"></a></td>
<td><a href="javascript:;" onMouseOver="MM_swapImage('downloads','','Images/nav_downloads_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/nav_downloads.gif" name="downloads" width="120" height="17" border="0" id="downloads"></a></td>
</tr>
<tr>
<td colspan="6"><img src="Images/prayer.jpg" width="720" height="140"></td>
</tr>
<tr>
<td bgcolor="#990033"><a href="javascript:;" onMouseOver="MM_swapImage('prayerrequest','','Images/nav_prayer_request_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/nav_prayer_request.gif" name="prayerrequest" width="120" height="17" border="0" id="prayerrequest"></a></td>
<td rowspan="4" align="center" valign="top"><table width="120" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td rowspan="4" align="center" valign="top"><img src="Images/spacer03.gif" width="1" height="70"></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td align="right"><img src="Images/cross.gif" width="20" height="1"></td>
<td align="left"><img src="Images/cross.gif" width="20" height="1"></td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
<td colspan="4" rowspan="3" align="left" valign="top" bgcolor="#660000"><a href="in_the_spot.htm" onMouseOver="MM_swapImage('inthespot','','Images/inthespotlight_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/inthespotlight.gif" name="inthespot" width="480" height="51" border="0" align="middle" id="inthespot"></a></td>
</tr>
<tr>
<td bgcolor="#990033"><a href="prayer_box.asp" onMouseOver="MM_swapImage('prayerbox','','Images/nav_prayer_box_on.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/nav_prayer_box.gif" name="prayerbox" width="120" height="17" border="0" id="prayerbox"></a></td>
</tr>
<tr>
<td bgcolor="#990033"><img src="Images/nav_placeholder.gif" width="120" height="17"></td>
</tr>
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CCCC99">
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table width="720" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCCC">
<td><img src="Images/spacer04.gif" width="180" height="1"></td>
<td><img src="Images/spacer05.gif" width="540" height="1"></td>
</tr>
<tr>
<td bgcolor="#999999">&nbsp;</td>
<td rowspan="2" bgcolor="#FFFFFF"><div align="center">OUR MISSION </div></td>
</tr>
<tr>
<td bgcolor="#999999">&nbsp;</td>
</tr>
<tr bgcolor="#CCCCCC">
<td>&nbsp;</td>
<td><div align="left"></div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td align="left" valign="top" bgcolor="#999999">&nbsp;</td>
<td bgcolor="#CCCC99">&nbsp;</td>
</tr>
<tr bgcolor="#CCCCCC">
<td align="left" valign="top" bgcolor="#999999"><p>&nbsp;</p></td>
<td valign="top" bgcolor="#FFFFFF"><form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="540" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Name:</td>
<td colspan="2"><input name="name" type="text" id="name" size="40" maxlength="50"></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input name="email" type="text" id="email" size="40" maxlength="50">
(not required) </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Subject:</td>
<td colspan="2"><input name="subject" type="text" id="subject" size="40" maxlength="50"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>Request:</td>
<td colspan="2"><textarea name="request" cols="40" rows="4" id="request"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td><input name="submit" type="submit" id="submit" value="submit"></td>
<td colspan="2">&nbsp;</td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1">
</form> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="left" valign="top" bgcolor="#999999">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="#CCCCCC">
<td>&nbsp;</td>
<td><div align="right">&copy; 2004, Sligo Seventh-day Adventist Church </div></td>
</tr>
</table>
<p>&nbsp;</p>

<%
'IF Request.Form("submit") = "submit" THEN

Dim mail
set mail=server.CreateObject("CDONTS.NewMail")
mail.From= Request.Form("email") ' like my.email.addr@comsoltech.com
mail.To = "rnowrang@yahoo.com" ' like john.doe@comsoltech.com
mail.Subject = "This is really hard"
mail.Body = Request.Form("request")
mail.BodyFormat = 0 ' 0 = HTML, 1 = Plain
mail.MailFormat = 1 ' 0 = MIME, 1 = Text
mail.Importance = 1 ' 0 =High, 1 = Medium, 2 = Low
'mail.attachFile ("c:\images\mypicture.gif") ' you can also attach files
mail.Send
set mail=nothing

'End If
%>

</body>
</html>
<%
PrayerRS.Close()
Set PrayerRS = Nothing
%>
 
not sure but does quotes make any difference:

mail.From= "Request.Form("email")"

instead of

mail.From= Request.Form("email")

and same with the mail.Body....


-VJ
 
I get a "page cannot be displayed error" HTTP 500 internal server
 
you may want to check whether your form parameter is getting passed correctly.

-VJ
 
Do a Response.Write something like this:

Response.Write Request.Form("email")

then try this to

Dim email
email=Request.Form("email")

Response.Write email -----check to see

Then do

mail.From= "email"

-VJ


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top