Forums

ASP

This topic is locked

Simple ASP mail code help

Posted 15 May 2007 04:02:46
1
has voted
15 May 2007 04:02:46 Shaun Maciejewski posted:
I barely know anything about ASP, but I am using this code I found online to do a contact form with file upload capability with a GoDaddy.com site. The code I copied it from only uses one field to type comments in, but mine has several. I'm not sure how to make it so all of the fields email to me (right now, only the first line sends in an email). Here is the code with my additions to email all fields:


[code] <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Set Upload = Server.CreateObject("Persits.Upload"
Upload.OverwriteFiles = False

'set the path to upload files to --- special permissions will have to be set on this folder to allow upload
Upload.SaveVirtual "/upload/"
%>
<% 'set up and send email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
'----edit these lines to fit your needs-----
objCDO.From = cStr(Upload.Form("EMAIL") 'email sent from
objCDO.To = " " 'email sent to
objCDO.Subject = "Contact Form Submission" 'subject line
objCDO.Body = cStr(Upload.Form("NAME")
cStr(Upload.Form("PHONE")
cStr(Upload.Form("COMPANY")
cStr(Upload.Form("EMAIL")
cStr(Upload.Form("ADDRESS")
cStr(Upload.Form("CITY")
cStr(Upload.Form("STATE")
cStr(Upload.Form("ZIP")
cStr(Upload.Form("PRODUCT")
cStr(Upload.Form("DECORATION")
cStr(Upload.Form("SIZE")
cStr(Upload.Form("COLORS")
cStr(Upload.Form("COMMENTS") 'body of email

'----do not edit these lines----------
objCDO.Send() 'send mail
Set objCDO = Nothing

'----edit this lines to fit your needs-----
response.redirect "send.html"
%>



Replies

Replied 16 May 2007 21:14:22
16 May 2007 21:14:22 dave blohm replied:
I believe that this is what you are looking to do. You turn objCDO.body into one long string. The vbcrlf at the end of each line will insert a line break. I've taken the liberty of adding labels in the body of the email so that you know just what each line is.

<pre id=code><font face=courier size=2 id=code>&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;%
Set Upload = Server.CreateObject("Persits.Upload"
Upload.OverwriteFiles = False

'set the path to upload files to --- special permissions will have to be set on this folder to allow upload
Upload.SaveVirtual "/upload/"
%&gt;
&lt;% 'set up and send email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
'----edit these lines to fit your needs-----
objCDO.From = cStr(Upload.Form("EMAIL") 'email sent from
objCDO.To = " " 'email sent to
objCDO.Subject = "Contact Form Submission" 'subject line
objCDO.Body = "Name: " & cStr(Upload.Form("NAME") & vbcrlf
objCDO.Body = objCDO.Body & "Phone: " & cStr(Upload.Form("PHONE") & vbcrlf
objCDO.Body = objCDO.Body & "Company: " & cStr(Upload.Form("COMPANY") & vbcrlf
objCDO.Body = objCDO.Body & "Email: " & cStr(Upload.Form("EMAIL") & vbcrlf
objCDO.Body = objCDO.Body & "Address: " & cStr(Upload.Form("ADDRESS") & vbcrlf
objCDO.Body = objCDO.Body & "City: " & cStr(Upload.Form("CITY") & vbcrlf
objCDO.Body = objCDO.Body & "State: " & cStr(Upload.Form("STATE") & vbcrlf
objCDO.Body = objCDO.Body & "ZIP: " & cStr(Upload.Form("ZIP") & vbcrlf
objCDO.Body = objCDO.Body & "Product: " & cStr(Upload.Form("PRODUCT") & vbcrlf
objCDO.Body = objCDO.Body & "Decoration: " & cStr(Upload.Form("DECORATION") & vbcrlf
objCDO.Body = objCDO.Body & "Size: " & cStr(Upload.Form("SIZE") & vbcrlf
objCDO.Body = objCDO.Body & "Colors: " & cStr(Upload.Form("COLORS") & vbcrlf
objCDO.Body = objCDO.Body & "Comments: " & cStr(Upload.Form("COMMENTS") & vbcrlf 'body of email

'----do not edit these lines----------
objCDO.Send() 'send mail
Set objCDO = Nothing

'----edit this lines to fit your needs-----
response.redirect "send.html"
%&gt;</font id=code></pre id=code>

Hope this helps.

- Doc

Progress is made by the discontent.

Edited by - daveblohm on 16 May 2007 21:15:15

Edited by - daveblohm on 16 May 2007 21:18:13

Reply to this topic