当前位置: 首页 > 图文教程 > 网络编程 > ASP > 发送带附件的HTML格式邮件例程可以带附件

ASP
ASP简单入门教程(2):ASP环境配置
ASP简单入门教程(3):ASP语法
ASP简单入门教程(4):ASP变量
ASP简单入门教程(5):ASP子程序
HTTP 500 - 内部服务器错误(补充内容)
ASP教程:IIS中配置多站点
ASP实例教程:Content Rotator (ASP 3.0)
ASP实例教程:Content Linking组件
ASP实例教程:Browser Capabilities组件
ASP实例教程:AdRotator组件
ASP实例教程:Dictionary对象
ASP实例教程:File对象
ASP实例教程:Drive对象
ASP实例教程:TextStream对象
关于学习ASP的20个测试题目
ASP实例教程:Server对象
ASP实例教程:Session对象
ASP实例教程:用户信息和服务器
asp教程:解决IIS安装问题
ASP网站数据库被挂木马的处理办法

ASP 中的 发送带附件的HTML格式邮件例程可以带附件


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

如何通过 ASP 来发送带附件、格式为 HTML 的邮件?下面提供了一个例程.

<%@ LANGUAGE=VBScript%>
<%
Response.Buffer = True
Response.Expires = 0

'创建对象实例
Set myMail = Server.CreateObject("CDONTS.NewMail")

'以下是将要发送的内容
HTML = "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>Sending CDONTS Email Using HTML</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "<p><font size=7>"
HTML = HTML & "This is a test mail in html<br>"
HTML = HTML & "Mail content here ...</font></p>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"

'发件人
myMail.From = "[email protected]"

'收件人
myMail.To = "[email protected]"

'密件抄送
myMail.Bcc = "[email protected]"

'抄送
myMail.Cc = "[email protected]"

'邮件的重要性
' 0 重要性低
' 1 重要性一般(默认)
' 2 重要性高
myMail.Importance = 2

'邮件主题
myMail.Subject = "Test mail in HTML"

'附件(注意 e:\test.txt 指的是服务器上的位置,如果使用相对路径,必须用 Server.MapPath 映射为真实路径)
myMail.AttachFile "e:\test.txt"

'NewMail 对象的文字格式
'0 表示该 Body 可包含超文本置标语言 (HTML)
'1 表示该 Body 只用于纯文本(默认值)
myMail.BodyFormat = 0

'NewMail 对象设置编码
'0 表示将采用 MIME 格式
'1 表示将采用连续的纯文本(默认值)
myMail.MailFormat = 0

'给邮件对象的文本赋值
myMail.Body = HTML

'将邮件发出
myMail.Send

'销毁对象实例,释放内存
Set myMail = Nothing
%>