日期:2012-01-05  浏览次数:20414 次

来源:http://www.aspfree.com/asp+/demos/emailhtml1.aspx

html1.htm
---------------------------------------------------------------------
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
</head>
<body>

<form method="post" name="frmEmail" action="email.aspx" >
发送邮件给:<input type="text" name="mailto" size="30" value="someone@chinaasp.com"><br><br>
<input type="submit" value="ASP+ 邮件发送" name="cmdSubmit">
</form>
</body>
</html>

emal.aspx
---------------------------------------------------------------------
<%@ Import Namespace="System.Web.Util" %>
<script language="VB" runat=server ID=Script1>

Sub Page_load(Sender as Object, E as EventArgs)

Dim MyMail as New MailMessage

MyMail.To = request.form("mailto")
MyMail.From = "webmaster"
MyMail.Subject = "webmaster给您发了一封电子邮件"

MyMail.BodyFormat = MailFormat.Html

MyMail.Body = "<html><body><h1><a href='http://www.chinaasp.com'>ChinaASP.com</a> 使用ASP+程序给你发了一封EMail! Hohoho!</h1></body></html>"
SmtpMail.Send(MyMail)

End Sub

</script>
<html>
<head>
<title>ASP+邮件发送</title>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
一封HTML格式邮件发送到了:<br>
<h1><% response.write(request.form("mailto")) %></h1>

</body>
</html>

--------------------------------------------------------------
我注意到了3点问题:
  • System.Web.Util
    居然在vs7 pdc preview的msdn library里面没有找到这个内容 :(
    所以没法了解更多详细内容了。
  • 为了让程序发送邮件,你必须开启smtp server,并正确设置之
    微软只使用自己的东西,这一点让我感觉很不爽。
    我使用的是拨号,用mmc编辑smtp server的属性,绑定smtp服务到我拨号时候获得的IP上,就能成功发送邮件了。
  • 让程序正确使用中文
    你必须在当前web目录的config.web中加上下列语句
       <globalization
       requestencoding="gb2312"
       responseencoding="gb2312"
       />
    或者你也可以
    修改winnt\complus\v2000.14.1812目录中的config.web文件
    <globalization
       requestencoding="gb2312"
       responseencoding="gb2312"
    />
  • 好好学习,天天向上