|
 |
access_asp thread: Re: Sending mail via ASP
Message #1 by "Al Vazquez" <avazqu1@p...> on Tue, 6 Aug 2002 15:24:48
|
|
One problem you may be having is that the mailFrom field of the email must
be a valid email address in the SMTP server. Which means people can't
send you emails from your form with a hotmail address.
This is great for an intranet, but on the Internet, it's a bother. I'm
unsure if there is a way to configure the email server to accept it, but
as a work around, just add their email address as the replyto field.
Cheers,
Al
> Hi all,
I have not done much ASP coding recently, and this is the first time I have
needed to send any mail using ASP.
I have trying to get this bit of code that I found on the net working, but
mail is not going out.
Anyone see any issues in the code?
<!-- The code here -->
<%
Dim strTo, strSubject, strBody, who, myName, myEmail, fileNum, docNum,
fName, lName, mName, generation, houseNum, direction, streetName,
streetType, city, state, zip, ssn1, ssn2, ssn3, dob1, dob2, dob3,
drvLicNum,
prevAddr
Dim objCDOMail 'The CDO object
'###############################################################
'## Change you@y... to your email address ##
'###############################################################
strTo = "you@y..."
'###############################################################
'## We can make the subject dynamic if you want ##
'## or you can just replace text inside "" to anything ##
'###############################################################
strSubject = "Email from website"
strBody = "Current date: " & date()
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "I am...: "
strBody = strBody & Request.Form("who")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "My name is: "
strBody = strBody & Request.Form("myName")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "My email address is: "
strBody = strBody & Request.Form("myEmail")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "File Number: "
strBody = strBody & Request.Form("fileNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Document Number: "
strBody = strBody & Request.Form("docNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "First Name: "
strBody = strBody & Request.Form("fName") & " "
strBody = strBody & Request.Form("lName") & ", "
strBody = strBody & Request.Form("mName") & " "
strBody = strBody & Request.Form("generation")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "House #: "
strBody = strBody & Request.Form("houseNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Direction: "
strBody = strBody & Request.Form("direction")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Street Name: "
strBody = strBody & Request.Form("streetName") & " "
strBody = strBody & Request.Form("streetType")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "City: "
strBody = strBody & Request.Form("city")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "State: "
strBody = strBody & Request.Form("state")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Zip Code: "
strBody = strBody & Request.Form("zip")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "SSN: "
strBody = strBody & Request.Form("ssn1") & "-" & Request.Form("ssn2") & "-"
& Request.Form("ssn3")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "DOB: "
strBody = strBody & Request.Form("dob1") & "/" & Request.Form("dob2") & "/"
& Request.Form("dob3")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Drivers Lic. #: "
strBody = strBody & Request.Form("drvLicNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Previous Address: "
strBody = strBody & Request.Form("prevAddr") & chr(10)
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
'###############################################################
'## Change yourname to reflect where the email is sent from ##
'###############################################################
objCDOMail.From = "yourname"
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
objCDOMail.Send
Set objCDOMail = Nothing
%>
Thanks
Charles
Message #2 by "Ostrander, Lewis" <OstranderL@M...> on Tue, 6 Aug 2002 10:36:05 -0400
|
|
You need to cut a lot of that code out. Just pull fields out of a front
page form. But remember to take out some of the extraneious code left by
the software.
Workable email form for both intranet and internet.
Dim myMail, body
body = body & "<font face=verdana size=2><b>" & " " & Request.Form("fname")
& " " & Request.Form("lname") & " " & "</b></font>"
body = body & "<br><font face=verdana size=2><b>" & " " &
Request.Form("address") & "</b></font>"
body = body & "<br><font face=verdana size=2><b>" & " " &
Request.Form("city") & "," & " " & Request.Form("state") & " " &
Request.Form("zip") & " " & "</b></font>"
body = body & "<br><br>"
body = body & "<br><font face=verdana size=2>(H)<b>" & " " &
Request.Form("homephone") & "</b></font>"
body = body & "<br><font face=verdana size=2>(W)<b>" & " " &
Request.Form("workphone") & "</b></font>"
body = body & "<br><font face=verdana size=2><b>" & " " &
Request.Form("email") & "</b></font>"
body = body & "<br><br>"
body = body & "<br><font face=verdana size=2>Employee ID:<b>" & " " &
Request.Form("employeeID") & "</b></font>"
body = body & "<br><font face=verdana size=2>Department Name:<b>" & " " &
Request.Form("department") & "</b></font>"
body = body & "<br><font face=verdana size=2>Location:<b>" & " " &
Request.Form("location") & "</b></font>"
body = body & "<br><br>"
response.write body
Set myMail = CreateObject("CDONTS.NewMail")
myMail.To = "email address" 'specify email address
myMail.From = Request.Form("email") 'additional email address is FROM the
user
myMail.Cc = Request.Form("email") 'sending a confirmation email
myMail.Subject = "Subject Here" 'spcify subject heading
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body = body
myMail.Send
Set MyMail=nothing
Response.Redirect "confirm.asp"
-----Original Message-----
From: Al Vazquez [mailto:avazqu1@p...]
Sent: Tuesday, August 06, 2002 11:25 AM
To: Access ASP
Subject: [access_asp] Re: Sending mail via ASP
One problem you may be having is that the mailFrom field of the email must
be a valid email address in the SMTP server. Which means people can't
send you emails from your form with a hotmail address.
This is great for an intranet, but on the Internet, it's a bother. I'm
unsure if there is a way to configure the email server to accept it, but
as a work around, just add their email address as the replyto field.
Cheers,
Al
> Hi all,
I have not done much ASP coding recently, and this is the first time I have
needed to send any mail using ASP.
I have trying to get this bit of code that I found on the net working, but
mail is not going out.
Anyone see any issues in the code?
<!-- The code here -->
<%
Dim strTo, strSubject, strBody, who, myName, myEmail, fileNum, docNum,
fName, lName, mName, generation, houseNum, direction, streetName,
streetType, city, state, zip, ssn1, ssn2, ssn3, dob1, dob2, dob3,
drvLicNum,
prevAddr
Dim objCDOMail 'The CDO object
'###############################################################
'## Change you@y... to your email address ##
'###############################################################
strTo = "you@y..."
'###############################################################
'## We can make the subject dynamic if you want ##
'## or you can just replace text inside "" to anything ##
'###############################################################
strSubject = "Email from website"
strBody = "Current date: " & date()
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "I am...: "
strBody = strBody & Request.Form("who")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "My name is: "
strBody = strBody & Request.Form("myName")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "My email address is: "
strBody = strBody & Request.Form("myEmail")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "File Number: "
strBody = strBody & Request.Form("fileNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Document Number: "
strBody = strBody & Request.Form("docNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "First Name: "
strBody = strBody & Request.Form("fName") & " "
strBody = strBody & Request.Form("lName") & ", "
strBody = strBody & Request.Form("mName") & " "
strBody = strBody & Request.Form("generation")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "House #: "
strBody = strBody & Request.Form("houseNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Direction: "
strBody = strBody & Request.Form("direction")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Street Name: "
strBody = strBody & Request.Form("streetName") & " "
strBody = strBody & Request.Form("streetType")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "City: "
strBody = strBody & Request.Form("city")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "State: "
strBody = strBody & Request.Form("state")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Zip Code: "
strBody = strBody & Request.Form("zip")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "SSN: "
strBody = strBody & Request.Form("ssn1") & "-" & Request.Form("ssn2") & "-"
& Request.Form("ssn3")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "DOB: "
strBody = strBody & Request.Form("dob1") & "/" & Request.Form("dob2") & "/"
& Request.Form("dob3")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Drivers Lic. #: "
strBody = strBody & Request.Form("drvLicNum")
strBody = strBody & vbCrLf
strBody = strBody & vbCrLf
strBody = strBody & "Previous Address: "
strBody = strBody & Request.Form("prevAddr") & chr(10)
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
'###############################################################
'## Change yourname to reflect where the email is sent from ##
'###############################################################
objCDOMail.From = "yourname"
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
objCDOMail.Send
Set objCDOMail = Nothing
%>
Thanks
Charles
|
|
 |