2007年10月24日 星期三

Jmail 範例程式

這支程式碼可以處理複數收件人的郵件寄發,使用密件副本讓收件者看不到你群發給誰。

Function SendMail(source,address,subject,body,smtpip)
Dim Sender
Dim Charset
Dim Region

Set jmail = Server.CreateObject("JMail.Message")
'寄信前的一些設定
jmail.Charset = "big5"
jmail.ContentType = "text/html"
jmail.From = source '寄件人
jmail.Subject = subject '郵件主指

jmail.Silent = true
jmail.ISOEncodeHeaders = false
jmail.HTMLBody = body
'////////////////////////////////////////////////////////////////////////////


'加入使用者地址,BCC是密件副本
for i = 0 to ubound(address)-1
jmail.AddRecipientBCC BCC(i)
next

'設定使用的SMTP的Server需要用到的用戶名稱和密碼。如果不需要寄件認證,可留白。
jmail.MailServerUserName = "exampleuser"
jmail.MailServerPassword = "examplepassword"


SendMail = jmail.Send(smtpip) '發出郵件
Set jmail = Nothing

End Function

Dim strContent '郵件內容
Dim BCC '收件人的陣列

strContent = "Something" '設定郵件內容
BCC = ("abc@123.com","cde@456.com","efg@789.com")
subject = "郵件主旨"
smtpip = "111.222.333.444" 'SMTP的地址

status = SendMail("sendmail@example.com",BCC,subject,strContent,smtpip)


沒有留言:

Google