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

Email a web form using ASP

Status
Not open for further replies.

IS300

MIS
Oct 29, 2003
121
0
0
CA
Is there a way to email the details of a web form?

I am trying to set up a feed back page that will allow the user to hit submit, then have the form email the information to me. I don't want Outlook to open up or anything like that. This is what I am trying to use:

<%
Set objNewMail = CreateObject("CDONTS.NewMail")
MsgFrom = "myemail@mydomain.com"
MsgTo = "youremail@yourdomain.com"
MsgSubject = Request.Form("EventName")
MsgMessage = Request.Form("EventDescription")

objNewMail.Send(MsgFrom, MsgTo, MSgSubject, MsgMessage)


%>

I am using IIS on Windows 2000 Server.

Thanks,
 
lets try to make this in one page :) and this is barebones feel free to dress it up

Code:
<html>
<body>
<%
' checking if there's information for the feedback
' this will seem built upsidedown, but it makes it easier for conditional checking
If Request.form("email") <> "" and request.form("message") <> "" then
    Set objNewMail = CreateObject("CDONTS.NewMail")
    With objNewMail
      .From = request("email")
      .To = "feedback@yourdomain.com"
      .Subject = Request.Form("Subject")
      .Body = Request.Form("Message")
    End With
        
    objNewMail.Send
%>
Thank you for your submission click <a href="index.asp">here to go back to the home page</a>
<%
Else
' this is the initial form
%>
<form method="post">
Your Email Address:<br>
<input type="text" name="email"><br>
Subject:<br>
<input type="text" name="Subject"><br>
Feedback:<br>
<textarea name="message"></textarea>
<br>
<input type="submit" value="Send Feedback">
</form>
<%
End If
%>
</html>
</body>
 
This doesn't appear to work. I don't get any error messages, and I do see the thank you message after. Are there components in IIS that I am missing?
 
you may need a <%response.expires=0%> at the beginning the page, it might be caching on you

if you're getting the thank you after posting, then it's working.

not to insult you or anything, but just to be sure, you did change the .to address in there to a valid email address right? make sure cdonts is installed and registered on your webserver, search the forum for cdonts there's many threads on getting it to work properly
 
Yes I did change the to address. To a few different ones to be sure. I have a feeling it might the the CDONTS. I'll look around for it.

Actually, I just got the test email I sent when I changed the .to field to my external account, but they are still not coming into my work account. I read something about having to configure SMTP on IIS on that server.
 
Hi.

Try this function that I use regulary (Win2003/IIS6)...

Public Sub SendEmail(sTo, sFrom, sSubject, sBody)
Set imsg = CreateObject("cdo.message")
Set iconf = CreateObject("cdo.configuration")
Set Flds = iconf.fields
Flds.Item(" = 2
Flds.Item(" = "Your SMTP Server name or IP address"
Flds.Update
With imsg
Set .Configuration = iconf
.To = sTo
.From = sFrom
.Subject = sSubject
.HTMLBody = sBody
.fields.Update
.Send
End With
Set imsg = Nothing
Set iconf = Nothing
End Sub


Obviously replace the text in the smtpserver with the relevant name or ip address and then use the function like so....

SendEmail "aperson@anaddress.com" "you@youraddress.com" "Subject of email" "This email was sent using the SendEmail function I got off Tek-Tips"

Hope this helps,

John.

mf_of_john.gif
 
Oops - there's supposed to be commas on the above example of use!!!!


SendEmail "aperson@anaddress.com","you@youraddress.com","Subject of email","This email was sent using the SendEmail function I got off Tek-Tips"


Donkey!

mf_of_john.gif
 
Recommend you use the CDO version. CDO(NTS) will work but is no longer available in new Windows servers. Win 2000 is the last OS that supports that method.



Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top