<%'By Dicky QQ:25941
Function JMail(Send_From,Send_To,Send_Subject,Send_Body)
'調用JMail組件
'發送E-mail函數
'參數:
'Send_From-發送者信箱
'Send_To-接受者信箱
'Send_Subject-郵件主題
'Send_Body-郵件內容
Dim JMail
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ' 郵件字元集,預設為"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否進行ISO編碼,預設為True
' 寄件者資訊(可用變數方式賦值)
JMail.From = Send_From ' 寄件者郵箱
JMail.FromName = "管理員" ' 寄件者姓名
JMail.Subject = Send_Subject ' 郵件主題
' 身分識別驗證
'JMail.MailServerUserName = "user" ' 身分識別驗證的使用者名稱
'JMail.MailServerPassword = "password" ' 身分識別驗證的密碼
' 設定優先權,範圍從1到5,越大的優先順序越高,3為普通
JMail.Priority = 3
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
' 加入一個收件者【變數Send_From:收件者地址】可以同一語句重複加入多個
JMail.AddRecipient(Send_From)
' 郵件主體(HTML(注意信件內連結附件的方式))
JMail.HTMLBody = UBBCode(Send_Body)
JMail.Body = HTMLDecode(UBBCode(Send_Body))
' 發送【調用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
'JMail.Send("user:password@smtp.21cn.com")
SendInfo=JMail.Send(Send_To)
' 關閉並清除對象
JMail.Close()
Set JMail = Nothing
End Function
Function Send_Mail(Send_From,Send_To,Send_Subject,Send_Body)
'調用Windows內建NewMail組件
'發送E-mail函數
'參數:
'Send_From-發送者信箱
'Send_To-接受者信箱
'Send_Subject-郵件主題
'Send_Body-郵件內容
Dim mailObject
Set mailObject = Server.CreateObject("CDONTS.NewMail")
mailObject.BodyFormat = 0
mailObject.MailFormat = 0
mailObject.From = Send_From
mailObject.To = Send_To
mailObject.Subject = Send_Subject
mailObject.Body = Send_Body
mailObject.Send()
Set mailObject = Nothing
If Err Then
Response.Write "<script language=javascript>alert('Error:"& Err.Number & Err.Description &"對不起,郵件發送失敗!:(');</script>"
Else
Response.Write "<script language=javascript>alert('恭喜,郵件發送成功!^_^');</script>"
End If
End Function %>