当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp+发送email

ASP
利用ASP输出excel文件一例
asp中使用js的encodeURIComponent
ASP动态网站制作中使用MYSQL的分析
如何编写通用的ASP防SQL注入攻击程序
ASP脚本变量、函数、过程和条件语句
ASP内建对象Application和Session
ASP基础教程:常用的 ASP ActiveX 组件
ASP程序漏洞解析及黑客入侵防范方法
ASP访问带多个参数的存储过程
用ASP和SQL语句动态的创建Access表
ASP初学者学习ASP指令
ASP开发中有用的函数(function)集合(1)
ASP开发中有用的函数(function)集合(2)
ASP开发中有用的函数(function)集合(3)
ASP网站程序自动升级实现的方法
ASP开发中的(VBScript)类基础学习
ASP代码:防止重复多次提交表单的方法
在ASP中使用类,实现模块化
ASP基础教程之学习ASP中子程序的应用
ASP技巧:ASP中三个常用语句的使用技巧

ASP 中的 asp+发送email


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 88 ::
收藏到网摘: n/a

       作者:飞鸟
  ---------------------------------------------------------------------------------------
  
  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="[email protected]"><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的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"
  />