当前位置: 首页 > 图文教程 > 网络编程 > ASP > 利用CDONTS发送邮件的ASP函数

ASP
bbs的数据结构和存储过程(二)
bbs的数据结构和存储过程(三)
聊天室自做 Follow Me
动态按钮生成器(上)
动态按钮生成器(下)
ASP直接调用EXCEL数据的例子(不用ODBC)
asp自动生成javascript检验函数
用Jmail做收取邮件附件的程序
简单的浮点论坛
ASP数据库恢复的代码
限制只能中文输入的方法
产生密码,记录到数据库,然后发送给用户。
一个基于web的QQ程序 1(xml+asp)
利用ASP生成EXECL文档
用ASP让用户访问指定页面
使用ASP程序对“HTML炸弹”进行屏蔽
实现ASP文件在线发邮件
用ASP+SQL Server为网页建一道防火墙
用Delphi开发ASP分页组件
如何在DataGrid控件中隐藏列

利用CDONTS发送邮件的ASP函数


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

  <%
'Last Updated By Recon On 05/14/2001
'On Error Resume Next

'利用CDONTS组件在Win2k上发送邮件

'发送普通邮件
SendMail "[email protected]", "[email protected]", "Normal Mail!", "Please check the attatchment!", 2, 0, "C:\Love.txt"

'发送HTML邮件
Dim m_fso, m_tf
Dim m_strHTML

Set m_fso = Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")
Set m_tf = m_fso.OpenTextFile("C:\Mail.htm", 1)
m_strHTML = m_tf.ReadAll

'Write m_strHTML
Set m_tf = Nothing
Set m_fso = Nothing

SendMail "[email protected]", "[email protected]", "HTML Mail!", m_strHTML, 2, 1, Null

'参数说明
'strFrom : 发件人Email
'strTo : 收件人Email
'strSubject : 信件主题
'strBody : 信件正文
'lngImportance : 信件重要性
' : 0 - 低重要性
' : 0 - 中等重要性(默认)
' : 0 - 高重要性
'lngAType : 信件格式
' : 为1时将邮件正文作为HTML(此时可以发送HTML邮件)
'strAttach : 附件的路径
Sub SendMail(strFrom, strTo, strSubject, strBody, lngImportance, lngAType, strAttach)
Dim objMail

Set objMail = Server.CreateObject("CDONTS.NEWMAIL")
With objMail

.From = strFrom
.To = strTo
.Subject = strSubject
.Body = strBody
.Importance = lngImportance

If lngAType = 1 Then
.BodyFormat = 0
.MailFormat = 0
End If

If IsEmpty(strAttach) = False And IsNull(strAttach) = False Then
.AttachFile strAttach
End If

.Send
End With
Set objMail = Nothing
End Sub
%>