利用CDONTS發送郵件的ASP函數

來源:互聯網
上載者:User
<%
'Last Updated By Recon On 05/14/2001
'On Error Resume Next

'利用CDONTS組件在Win2k上發送郵件

'發送普通郵件
SendMail "admin@ny.com", "iamchn@263.net", "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 "admin@ny.com", "iamchn@263.net", "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
%>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.