ASP發送郵件到指定地址函數_ASP E-mail發送函數

<%
'SendEmail(發送人Email,發送者,收件人Email,郵件標題,郵件內容,smtp服務器地址,郵件服務器驗證密碼)
Function SendEmail(frommail,fromname,tomail,subject,content,mailserver,ServerPass)
    On Error Resume Next
    Set JMail = server.CreateObject("JMail.Message") '創建Jmail對象
    JMail.Logging = True '是否使用日誌
    JMail.charset = "gb2312" '郵件編碼,缺省爲"US-ASCII",最好加上,免得出現亂碼
    JMail.ContentType = "text/html" '郵件的格式,text/plain爲純文本型
    JMail.From = frommail '發送郵件地址,最好寫郵件服務器驗證的郵箱賬號
    JMail.FromName = fromname '發送者,可以隨便填寫
    JMail.AddRecipient tomail '要發送到的郵件地址
    JMail.Subject = subject '郵件的標題
    JMail.Priority = 3 '郵件的優先級
    JMail.Body = content '郵件的內容

    JMail.MailServerUserName = frommail '郵件服務器驗證賬號
    JMail.MailServerPassword = ServerPass '郵件服務器驗證密碼
    JMail.Send(mailserver) '通過郵件服務器smtp發送郵件

    Set JMail = Nothing '關閉對象

    If Err.Number<>0 Then '錯誤處理
        SendEmail = False
    Else
        SendEmail = True
    End If
End Function
%>
<%
'發送測試..
'以下用的是QQ郵箱的SMTP服務
'你也可以用你的QQ郵箱來發..不過QQ郵箱默認是沒有開啓SMTP服務的
'需要自己進入QQ郵箱賬戶開啓SMTP服務服務才能發郵件的。

'把 [email protected] 改成你的收件郵箱測試一下吧

dim Send
Send=SendEmail("[email protected]","新興網絡","[email protected]","我是標題","我是內容","smtp.qq.com","www.newxing.com")
If Send then
   response.write "發送成功"
Else
   response.write "發送失敗"
End If
%>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章