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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you send an email in asp?

Status
Not open for further replies.

meeble

Programmer
Sep 24, 2002
137
GB
Hello,

I have a form on my site that when users fill it in, I'd like it to email me the results. I can do this using .php and cgi but this site is being done in .asp. I have the form elements, does anyone have a good script or can they point me to one on the web?

Much appreciated,

James
 
a lot of people use CDONTS. I think there is a setting in the web server to allow email. here is some code.


Dim myCDO, FromAddress, MailList, sSubject, sBody

FromAddress = "from@f.com"
MailList = "To@t.com"
sSubject = "Hi"
sBody = "Howdy"

Set myCDO = Server.CreateObject("CDONTS.NewMail")

myCDO.send FromAddress, MailList, sSubject, sBody

Set myCDO = Nothing


Kris
- To err is human, but to really foul things up requires a computer.
 
Hello,

I have tried to make up a script but although it seems to work, I don't receive any email and I know the SMTP server is working fine. I have made it a self referencing form. What is wrong with the code please:

<%
On Error Resume Next

sub SendMail(strServer, strSubject, strrealname, strcompname, strposition, stremail, strTelephone_Number, strAddress, strEnquiry, strInformation_required)
Dim objC
dim objM
dim strDefaultEmail
dim lngErrNumber
dim strErrSource
dim strErrDescription

Set objC = CreateObject(&quot;CDO.Configuration&quot;)

objC.Fields(&quot; = strServer
objC.Fields(&quot; = 25
objC.Fields(&quot; = 2
objC.Fields.Update

Set objM = CreateObject(&quot;CDO.Message&quot;)
Set objM.Configuration = objC
objM.Subject = strSubject

if Err.number = 0 then
objM.send
end if

set objM = nothing
set objC = nothing
end sub

SendMail Request.Form(&quot;realname&quot;), Request.Form(&quot;compname&quot;), Request.Form(&quot;position&quot;), Request.Form(&quot;email&quot;), Request.Form(&quot;Telephone_Number&quot;), Request.Form(&quot;Address&quot;), Request.Form(&quot;Enquiry&quot;), Request.Form(&quot;Information_required&quot;)
%>

<html>
<head>
</head>

<form method=&quot;post&quot; action=&quot;contact.asp&quot; id=&quot;frmEmail&quot; name=&quot;frmEmail&quot;>
<input type=&quot;hidden&quot; name=&quot;Server&quot; value=&quot;smtp.xxx.co.uk&quot;>
<input type=&quot;hidden&quot; name=&quot;To&quot; value=&quot;test@xxx.co.uk&quot;>
<input type=&quot;hidden&quot; name=&quot;Subject&quot; value=&quot;Web enquiry&quot;>
<body bgcolor=&quot;#FFFFFF&quot; topmargin=&quot;9&quot;>

<input type=&quot;text&quot; name=&quot;realname&quot; size=&quot;20&quot;>
<input type=&quot;text&quot; name=&quot;compname&quot; size=&quot;20&quot;>
<input type=&quot;text&quot; name=&quot;position&quot; size=&quot;20&quot;>
<input type=&quot;text&quot; name=&quot;email&quot; size=&quot;20&quot;>
<input type=&quot;text&quot; name=&quot;Telephone_Number&quot; size=&quot;20&quot;>
<textarea cols=&quot;15&quot; rows=&quot;4&quot; name=&quot;Address&quot;></textarea>
<textarea cols=&quot;24&quot; rows=&quot;8&quot; name=&quot;Enquiry&quot; class=&quot;box&quot;></textarea>
<select name=&quot;Information_required&quot;><option>1</option></select>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Send&quot;>
<INPUT TYPE=&quot;RESET&quot; VALUE=&quot;Clear&quot;>
</FORM>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top