Jmail發信的實例,模塊化隨時調用

- 中國WEB開發者網絡 (http://www.webasp.net)
-- 技術教程 (http://www.webasp.net/article/)
--- Jmail發信的實例,模塊化隨時調用 (http://www.webasp.net/article/13/12706.htm)
-- 作者:未知
-- 發佈日期: 2004-08-30
一個用jmail發信的過程,及使用方法.
發信時,直接調用這個過程就行了。


<%
dim str,HtmlBody
HtmlBody="<html><body bgcolor='red' topmargin='40'><p align='center'>I Love 2Yup!</p></html>"
str=JmailSend( "hello","ILoveYou",true,HtmlBody,"youname@domain.com",youname@sina.com,
"hello","smtp.sina.com.cn","hello","Password")

if str="Y" then
response.write("發送成功")
else
response.write("發送失敗!請重試!")
end if
'=================================================
'函數名:JmailSend
'作 用:用Jmail發送郵件
'參 數:Subject 郵件標題
' Body 郵件內容
' Body 郵件內容
' isHtml 是否發送Html格式郵件 (true 是)
' HtmlBody Html格式郵件內容
'    MailTo 收件人Email
' From 發件人Email
' FromName 發件人姓名
' Smtp smtp服務器
' Username 郵箱用戶名
' Password 郵箱密碼
'返回值:JmailSend="N" 發送失敗 JmailSend="Y" 發送成功
'~~~~~~~~~~suercool~~~~~

'=================================================

function JmailSend(Subject,Body,isHtml,HtmlBody,MailTo,From,FromName,Smtp,Username,Password)
dim JmailMsg
set JmailMsg=server.createobject("jmail.message")
JmailMsg.mailserverusername=Username
JmailMsg.mailserverpassword=Password

JmailMsg.addrecipient MailTo
JmailMsg.from=From
JmailMsg.fromname=FromName

JmailMsg.charset="gb2312"
JmailMsg.logging=true
JmailMsg.silent=true

JmailMsg.subject=Subject
JmailMsg.body=Body
if isHtml=true then JmailMsg.htmlbody=HtmlBody

if not JmailMsg.send(Smtp) then
JmailSend="N"
else
JmailSend="Y"
end if
JmailMsg.close
set JmailMsg=nothing
end function
%>

webasp.net