当前位置导航:炫浪网>>网络学院>>网页制作>>ASP教程

发送带附件的HTML格式邮件例程

  发送带附件的HTML格式邮件例程


  如何通过 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
%>


 
相关内容
赞助商链接