top
Loading...
利用CDONTS發送郵件的ASP函數
<%
'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
%>

北斗有巢氏 有巢氏北斗