| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
email forms cdonts
I downloaded asp code for a form from http://www.planet-source-code.com/v...&txtCodeId=6386
The code sends an HTML email with some basic information to an email account and a link to view the completed form. It uses CDONTS to send the information. The link contains all the information the user entered on the form and when you click on the link, it populates the form with that information. However, I don't receive the e-mail. I inserted my e-mail address but never received the form. I e-mailed the author but never heard back from him. I'm sure it's something I am doing wrong. Can anyone help me? Here is the code for the emailform: <%@ Language=VBScript %> <HTML> <HEAD> <TITLE></TITLE> <!--#include file="scripts.asp"--> </HEAD> <BODY> <H2><FONT COLOR="#336699">Email Form</FONT></H2> <FORM ACTION="submitform.asp" Method="Post" > <INPUT TYPE="hidden" NAME="FormName" VALUE="emailform.asp"> <INPUT TYPE="hidden" NAME="subject" VALUE="Email Form Sample"> <INPUT TYPE="hidden" NAME="SendTo" VALUE="lindajo13@hotmail.com"> <TABLE WIDTH="274" CELLPADDING="0" CELLSPACING="0"> <TR> <TD COLSPAN="2" ALIGN="CENTER" WIDTH="274"></TD> </TR> <TR> <TD WIDTH="88">Name:</TD> <TD WIDTH="186"><INPUT TYPE="TEXT" NAME="txtName" <%Call RequestInfo("txtName", "")%>></TD> </TR> <TR> <TD WIDTH="88">Address:</TD> <TD WIDTH="186"><INPUT TYPE="TEXT" NAME="txtAddress" <%Call RequestInfo("txtAddress", "")%>></TD> </TR> <TR> <TD WIDTH="88">Phone:</TD> <TD WIDTH="186"><INPUT TYPE="TEXT" NAME="txtPhone" <%Call RequestInfo("txtPhone", "")%>></TD> </TR> <TR> <TD WIDTH="88">Email:</TD> <TD WIDTH="186"><INPUT TYPE="TEXT" NAME="txtEmail" <%Call RequestInfo("txtEmail", "")%>></TD> </TR> <TR> <TD WIDTH="88">Gender:</TD> <TD WIDTH="186"><INPUT TYPE="RADIO" NAME="radGender" VALUE="m" <%Call RequestInfo("radGender", "m")%>>Male <INPUT TYPE="RADIO" NAME="radGender" VALUE="f" <%Call RequestInfo("radGender", "f")%>>Female</TD> </TR> <TR> </TR> <TR> <TD COLSPAN="2" WIDTH="274"><BR><B>Check all that apply:</B></TD> </TR> <TR> <TD COLSPAN="2"> <INPUT TYPE="CHECKBOX" NAME="chkVB" <%Call RequestInfo("chkVB", "on")%>> Visual Basic<BR> <INPUT TYPE="CHECKBOX" NAME="chkASP" <%Call RequestInfo("chkASP", "on")%>> ASP<BR> <INPUT TYPE="CHECKBOX" NAME="chkJava" <%Call RequestInfo("chkJava", "on")%>> Java<BR> <INPUT TYPE="CHECKBOX" NAME="chkOther" <%Call RequestInfo("chkOther", "on")%>> Other <INPUT TYPE="TEXT" NAME="txtOther" <%Call RequestInfo("txtOther", "")%>><BR><BR></TD> </TR> <TR> <TD COLSPAN="2" WIDTH="274" ALIGN="RIGHT"><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Send Now!"></TD> </TR> </TABLE></FORM> </BODY> </HTML> Here is the code for the submitform: <% '======================================' 'if have any comments, let me know. 'email richardt@proactivect.com '======================================' 'change this to the appropriate http Const strHTTP = "http://lindadesk/" 'get current date strDate = Date() 'get form information strFormName = Request("FormName") strSubject = Request("subject") strSendTo = Request("SendTo") strName = Request("txtName") strPhone = Request("txtPhone") 'if no information entered for email use your own if instr(Request("txtEmail"), "@") <> 0 then strFrom = Request("txtEmail") else strFrom = strSendTo end if 'concat URL information strURLInfo = strHTTP & strFormName & "?" & Request.Form() 'create the HTML for email strHTML = "<HTML> <HEAD> <TITLE></TITLE> </HEAD>" strHTML = strHTML & "<BODY>" strHTML = strHTML & "<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=0>" strHTML = strHTML & "<TR>" 'use some graphics for email strHTML = strHTML & "<TD><IMG SRC=" & strHTTP & "emailbanner.JPG BORDER=0></TD>" strHTML = strHTML & "</TR>" 'include basic info in email strHTML = strHTML & "<TR>" strHTML = strHTML & "<TD>" strHTML = strHTML & "<BR>Date: " & strDate strHTML = strHTML & "<BR>Subject: " & strSubject strHTML = strHTML & "<BR>Requested by: " & strName strHTML = strHTML & "<BR>Phone: " & strPhone if strFrom <> strSendTo then strHTML = strHTML & "<BR>Email: <a href=mailto:" & strFrom & ">" & strFrom & "</a>" else strHTML = strHTML & "<BR>Email: UNKNOWN" end if 'add hyperlink to form in email strHTML = strHTML & "<BR><BR>" strHTML = strHTML & "<A HREF=" & strURLInfo & "><IMG SRC=" & strHTTP & "form.gif WIDTH=16 HEIGHT=16 BORDER=0>Click here</A>" strHTML = strHTML & " to view completed form." strHTML = strHTML & "</TD>" strHTML = strHTML & "</TR>" strHTML = strHTML & "<TR>" strHTML = strHTML & "<TD></TD>" strHTML = strHTML & "</TR>" strHTML = strHTML & "</TABLE>" strHTML = strHTML & "</BODY>" strHTML = strHTML & "</HTML>" 'time to send the email Dim objCDO Set objCDO = Server.CreateObject("CDONTS.NewMail") objCDO.To = strSendTo objCDO.From = strFrom objCDO.Subject = strName & " - " & strSubject objCDO.BodyFormat = 0 objCDO.MailFormat = 0 objCDO.Body = strHTML objCDO.Send set objCDO = nothing 'redirect to the "Thanks" page Response.Redirect strHTTP & "submitdone.htm" %> Rianashley email: lindajo13@hotmail.com. |
|
#2
|
||||
|
||||
|
Hi
Let's presume that because you are changing a published and well tested script that the fault lies with your system's ability to send the email, rather than a bug in the form. Try creating the following ASP script: Code:
<%
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.To = "send.to@emailaddress.com"
objCDO.From = "sent.from@emailaddress.com"
objCDO.Subject = "Test message"
objCDO.BodyFormat = 0
objCDO.MailFormat = 0
objCDO.Body = "<html><body>Test message</body></html>"
objCDO.Send
set objCDO = nothing
%>
If this script does not work we might have to presume that CDO is not working correctly MK |
|
#3
|
|||
|
|||
|
Okay, I will try this. Thanks.
Rianashley |
|
#4
|
|||
|
|||
|
If you are testing this locally, make sure you have your SMTP service installed and running. Also... What OS version are you running on? CDONTS does not work on XP or Windows 2003. You would have to use CDOsys. More info at MSDN here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_creating_a_message_object.asp Another item to look for is that the send to and from addresses must be correctly formatted email addresses or the message will not be sent; without any error or warning messages. |
|
#5
|
|||
|
|||
|
CDONTS email
I have Windows 2000 Professional. I am also running the Service Pack 4 for Windows 2000 Professional. Do you know if this may present a problem?
Rianashley Last edited by rianashley : August 5th, 2004 at 10:37 AM. Reason: typo |
|
#6
|
|||
|
|||
|
Windows 2000 still supports CDONTS as well as CDOSYS. However, it is not a bad idea to start using CDO instead. It is not that much different and will guarantee that your scripts will work on future upgrades.
Here is a sample that uses the pickup directory of SMTP running on the local machine. Other schemas are available at the link I posted earlier, for example, network send for a remote SMTP server, or even posting directly to a newsgroup. Choose "Configuring the Message Object" from the menu for more info on this. Dim iMsg Dim iConf Dim Flds Const cdoSendUsingPickup = 1 set iMsg = CreateObject("CDO.Message") set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPickup .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")="c:\Inetpub\mailroot\pickup" .Update End With With iMsg Set .Configuration = iConf .From = "From<from@domain.com>" .Subject = "Subject of Message" .To = "someone@somedomain.com" ' .cc = "" ' .bcc = "" .TextBody = "Text only Message body goes here" ' .HTMLBody = "for HTML formatted messages" .send End With Set iMsg = Nothing Set iConf = Nothing Set Flds = Nothing |
|
#7
|
|||
|
|||
|
Okay, I'm sure it's probably something I'm doing wrong as I am new to this. I will look into using CDOSYS as well. Thanks for your help.
Rianashley |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > email forms cdonts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|