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

ASP
ADO如何提供异动功能?(BIG5)
从数据库中动态选取下拉列表的方法
数 据 库 设 计 经 验 谈
用SQL实现分布式数据复制
NT4的ODBC与SQL7相连,不支持中文?
大部分ADO的错误码对应的含义
ASP+中取代ASP的RS(Remote Scripting)技术的Framework
利用Page.IsPostBack属性保持用户输入的Framework
用VB6读写数据库中的图片
VisualInterDev6.0七种实现分页显示的方法
利用ASP获得图象的实际尺寸的示例
5个实用的ASP网站功能(GIB5)
在ASP中用集合成批操作数据库
用asp管理sql server数据库
用asp处理access数据库
使用速度更快的OLEDB取代ODBC连结
对Query字段进行Encode操作的一点看法
用ASP语言实现对SQL SERVER 数据库的操作
Microsoft SQL Server 7.0 备份及恢复相关问题
Microsoft SQL Server 7.0数据库升级转换问题

利用CDONTS发送邮件的ASP函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 68 ::
收藏到网摘: 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
%>