Forums
This topic is locked
CDONTS or CDOSYS?? Please help!!!
Posted 24 Nov 2003 13:04:25
1
has voted
24 Nov 2003 13:04:25 Billy Griffiths posted:
I want to create a page that submits to e-mail. A form gets submitted to the page below. This will not work. Can anyone help? Is there a tutorial that will help me with this? <%
DIM strEmail, strName, strComments, mail, reply, objMail
strEmail = request.form("Email"
strName = request.form("Name"
strComments = request.form("Comments"
mail = " "
reply = request.form("Email"
Set objMail = Server.CreateObject("CDONTS.NewMail"
objMail.From = reply
objMail.Subject = "MAIL FROM CLIENT"
objMail.To = mail
objMail.Body = "Email: " & strEmail & vbCrLf & _
"Name: " & strName & vbCrLf & _
"Comments: " & vbCrLf & strComments
objMail.Send
Set objMail = nothing
%>
<P>
<%
Response.Write(strName)
%></P>
<P>Thank you for emailing me.</P>
Xcalibur
Cape Town - South Africa
Replies
Replied 24 Nov 2003 14:30:27
24 Nov 2003 14:30:27 Dave Thomas replied:
This should do it.
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT"%>
<%
Response.Buffer = True
Dim strBody
Dim objCDOMail
Dim strMyEmailAddress
Dim strReturnEmailAddress
strMyEmailAddress = " "
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("Email"
'Initialse strBody string with the body of the e-mail
strBody = "<h3>E-mail sent from THE BLAH BLAH SITE</h3>"
strBody = strBody & "<br><br>Hello."
strBody = strBody & "<br><br>Some text"
strBody = strBody & "<br>Mail from: " & Request.Form("Name"
strBody = strBody & "<br>Email Address " & Request.Form("Email"
strBody = strBody & "<hr>"
strbody = strBody & "<b>Comments/Enquiry::</b><br>"
strBody = strBody & Replace(Request("Comments", VbCrLf, "<BR>"
strBody = strBody & "<br><br>"
strBody = strBody & "<hr>"
strBody = strBody & "Your email footer info goes here"
' THE BODY OF EMAIL COULD GO ON FOREVER, MAKE IT UP AS YOU WISH.
'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
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
'Send the e-mail
'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail"
'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = Request.Form("name" & " <" & strReturnEmailAddress & ">"
'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress
'Set the subject of the e-mail
objCDOMail.Subject = "MAIL FROM CLIENT"
'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0
'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
'Set the main body of the e-mail
objCDOMail.Body = strBody
'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
'Send the e-mail
objCDOMail.Send
'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<title>Thank you for sending us your comments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p></p>
<p></p>
<p></p>
<p align="center">Thank you for Emailing me, I will be in touch shortly.</p>
</body>
</html>
</font id=code></pre id=code>
Regards,
Dave
UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="VBSCRIPT"%>
<%
Response.Buffer = True
Dim strBody
Dim objCDOMail
Dim strMyEmailAddress
Dim strReturnEmailAddress
strMyEmailAddress = " "
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("Email"
'Initialse strBody string with the body of the e-mail
strBody = "<h3>E-mail sent from THE BLAH BLAH SITE</h3>"
strBody = strBody & "<br><br>Hello."
strBody = strBody & "<br><br>Some text"
strBody = strBody & "<br>Mail from: " & Request.Form("Name"
strBody = strBody & "<br>Email Address " & Request.Form("Email"
strBody = strBody & "<hr>"
strbody = strBody & "<b>Comments/Enquiry::</b><br>"
strBody = strBody & Replace(Request("Comments", VbCrLf, "<BR>"
strBody = strBody & "<br><br>"
strBody = strBody & "<hr>"
strBody = strBody & "Your email footer info goes here"
' THE BODY OF EMAIL COULD GO ON FOREVER, MAKE IT UP AS YOU WISH.
'Check to see if the user has entered an e-mail address and that it is a valid address otherwise set the e-mail address to your own otherwise the e-mail will be rejected
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
'Send the e-mail
'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail"
'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = Request.Form("name" & " <" & strReturnEmailAddress & ">"
'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress
'Set the subject of the e-mail
objCDOMail.Subject = "MAIL FROM CLIENT"
'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0
'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
'Set the main body of the e-mail
objCDOMail.Body = strBody
'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
'Send the e-mail
objCDOMail.Send
'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<title>Thank you for sending us your comments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p></p>
<p></p>
<p></p>
<p align="center">Thank you for Emailing me, I will be in touch shortly.</p>
</body>
</html>
</font id=code></pre id=code>
Regards,
Dave
UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 24 Nov 2003 15:00:51
24 Nov 2003 15:00:51 Billy Griffiths replied:
I have tried this but still no luck. I am running Win 2000 with IIS 5.0. Can this be why? It gives me the "successfully sent" message, but no e-mail in my mailbox. ish!!
Xcalibur
Cape Town - South Africa
Xcalibur
Cape Town - South Africa
Replied 24 Nov 2003 19:00:43
24 Nov 2003 19:00:43 Dave Thomas replied:
you sending the form from a web page? or a local machine running iis 5.0?
that code works on a web page, i use it myself, all i did was modify the body and email info.
Regards,
Dave
UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
that code works on a web page, i use it myself, all i did was modify the body and email info.
Regards,
Dave
UD4 | Flash 5/MX | Studio MX | SQL | Access | ASP/VBScript | XP-Pro
Replied 25 Nov 2003 05:46:41
25 Nov 2003 05:46:41 Dave Blohm replied:
On Win2K do the following:
<%
Set objCDO = Server.CreateObject("CDO.Message"
With objCDO
.To = " "
'.Cc =
'.Bcc =
.From = request.form("Name" & "<" & request.form("Email" & ">"
.Subject = "Mail From Client"
.TextBody = request.form("Comments"
'.HTMLBody=
.Send
End With
Set objCDO = Nothing
Response.Write request.form("Name" & ",<br><br>Thank you for emailing me."
%>
Unless there is a specific reason for using HTML as the vehicle for your email (such as including images) there is no reason to send anything other than plain text. I use this script on many many apps and it works like a charm...
Hope this helps,
Doc
Rangewalk Digital Studios
Edited by - on 25 Nov 2003 05:49:10
<%
Set objCDO = Server.CreateObject("CDO.Message"
With objCDO
.To = " "
'.Cc =
'.Bcc =
.From = request.form("Name" & "<" & request.form("Email" & ">"
.Subject = "Mail From Client"
.TextBody = request.form("Comments"
'.HTMLBody=
.Send
End With
Set objCDO = Nothing
Response.Write request.form("Name" & ",<br><br>Thank you for emailing me."
%>
Unless there is a specific reason for using HTML as the vehicle for your email (such as including images) there is no reason to send anything other than plain text. I use this script on many many apps and it works like a charm...
Hope this helps,
Doc
Rangewalk Digital Studios
Edited by - on 25 Nov 2003 05:49:10