如何使用表单发送电子邮件?
formToEmail.htm
' 表单.
FORM METHOD="POST" ACTION="formToEmail.asp">
P>
收件人: INPUT SIZE=30 NAME="recipient" MAXLENGTH=200>
P>
发件人: INPUT SIZE=30 NAME="sender" MAXLENGTH=200>
P>
主题: INPUT SIZE=30 NAME="subject" MAXLENGTH=512>
P>
内容一: TEXTAREA ROWS=2 COLS=60 NAME="messageline1"> /TEXTAREA>
P>
内容二: TEXTAREA ROWS=2 COLS=60 NAME="messageline2"> /TEXTAREA>
/PRE>
INPUT TYPE=submit VALUE="发送">
formToEmail.asp
' 处理接收和发送邮件.
%
Set mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
recipient = Request.Form("recipient")
sender = Request.Form("sender")
subject = Request.Form("subject")
message = Request.Form("messageline1")
message = message vbCRLF
message = message vbCRLF
message = message Request.Form("messageline2")
mailserver = "www.intels.net"
' 写上邮件服务器.
result = mailer.SendMail(mailserver, recipient, sender, subject, message)
%>
% If "" = result Then %>
恭喜,邮件发送成功!
% Else %>
抱歉,邮件发送失败!
H2>
%= result %>
/H2>
% End If %> [1]