8 replies
by ghousem
get the form contents and store in Database using INSERT and Use CDONTS.NewMail component to send e-mail, you need SMTP running on the Webserver.
Ghouse Mohiuddin Khadarabad
by rmg
by jpalmera
Yes, it is very much possible. For an asp file "tosend.asp" having the source:
You can make a recieving file "esender.asp" with the following code:
<%@ Language=VBScript %>
<% 'the following code will input the email information into the table "emailtrack" containing fields "to","from","subject","body", in the sql database "emails" and the servermachiname "Myserver"
dim connectstr 'the connection string
connectstr="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Emails;Data Source=Myserver" 'if you are using NT integrated security and logged on an account with sufficient access privileges to the database
dim conn
set conn=server.createobject("adodb.connection")
with conn
.open connectstr
.execute "insert into emailtrack(to,from,subject,body) values('" & request.form("rcptaddr") & "','"& request.form("sndraddr") & "','" & request.form("subject") & "','" & request.form("body") & "')" 'assuming all the fields to be entered are strings
.close
end with
set conn=nothing
'to send an email
dim objsendmail
set objsendmail=server.CreateObject("cdonts.newmail")
objsendmail.To="reciever@someaddress.com"
objsendmail.From="sender@someaddress.com"
objsendmail.Subject="This is a test"
objsendmail.Body="This is the body of the test"
objsendmail.Send
%>
by rmg
by webmaster
Yes Ryan,
The answer involves what is called ADO or Active Data Object from Microsoft.
Simple algorithm:
1. read the form variables (using request.form("fieldName"))
2. process the form data (strip any single quotes 3. from the input)
4. create the ADO connection to the database (usually through ODBC)
5. setup the SQL INSERT statement
6. execute the SQL
7. check the result
You can find specific examples of this on MSDN, 15 seconds, WROX, 2 guys from rolla, etc. Or if you're in a hurry, drop me an email.
Good luck.
by webmaster
Sorry, I didn't see your second requirement for sending email. Yes, as others have mentioned, the CDO or CDONTS component can send email using an SMTP server. Your script can do this after it stores the form contents in the database.
I use a component called ASPQMail from ServerObjects.com to do this same thing. Why? Because I bought this thing way back before CDO was available and I'm in the habit of using it.
by rmg
by rmg
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending