Click to See Complete Forum and Search --> : ASP mailform


jochem
01-20-2004, 12:03 AM
I want to insert a mailform on my site in which users don't need to fill out my email address. The email is sent by pressing the 'send' button. It links to a page on which e.g. the sender's name is being repeated using Response.Write. This part works fine.

But, I don't know how to get the email sent to my email address accompanied by a fixed subject line. Which code do I need?

ASP is all new to me!!

Cheers, Jochem :cool:

gil davis
01-20-2004, 07:40 AM
This page has many e-mail examples using ASP:
http://www.example-code.com/asp/email.asp

jochem
01-20-2004, 08:52 AM
Thanx, the link looks good. I'll have a look at it.

Cheers, Jochem :cool:

Bullschmidt
02-05-2004, 04:49 AM
Also there are some e-mail examples in the Samples area of www.asp101.com.

slyfox
02-06-2004, 07:42 AM
first page:

<form name"mailme" action="sendmail.asp" method="post">
name:<input name="name" type="text"><br>
email:<input name="email" type="text"><br>
message:<textarea name="message"></textarea>
</form>


second page: (sendmail.asp)

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
var aName = Request.Form("name");
var aEmail = Request.Form("email");
var aMessage = Request.Form("message");
aMessage = aMessage.replace(/\r/g, "<br>");
var sendMail = Server.CreateObject("CDONTS.NewMail");

var htmail = '<html>';
htmail += '<head>';
htmail += '<title>New Email Received</title>';
htmail += '</head>';
htmail += '<body>';
htmail += '<b>Name of sender:</b> ' + aName + '<br>';
htmail += 'Message: ' + aMessage;
htmail += '</body>';
htmail += '</html>';

sendMail.To = "your@email_address.com";
sendMail.From = aEmail; /* or replace it with aName + "<" + aEmail + ">";*/
/*sendMail.Value("Reply-To") = aName + "<" + aEmail + ">";*/ /*You won't be needing this*/
sendMail.Subject = "Your subject here!";
sendMail.Body = htmail;
sendMail.Importance = 1; /* 1 = normal, 2 = high, 3 = low*/
sendMail.BodyFormat = 0;
sendMail.MailFormat = 0;
sendMail.Send();
sendMail.Delete;

Response.Redirect("thankyou.htm");
%>

buntine
02-06-2004, 08:04 AM
Which componect are you using? If it is CDONTS then refer to the post above.

slyfox
02-06-2004, 09:49 AM
oh yes, if your page is running on a winnt or win2000 server then you have nothing to worry about...