Jmail組件發(fā)送及收郵件的asp代碼 二
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
jmail實(shí)例:[br] [br][br][br]post.asp代碼: [br][br] [br] [br]
i love 2yup! " [br]str=jmailsend( "2yup","iloveyou",true,htmlbody,"2yup@2yup.com","suercool@sina.com","suercool","smtp.sina.com.cn","suercool","password") [br][br]if str="y" then [br]response.write("發(fā)送成功") [br]else [br]response.write("發(fā)送失敗!請重試!") [br]end if [br]'================================================= [br]'函數(shù)名:jmailsend [br]'作 用:用jmail發(fā)送郵件 [br]'參 數(shù):subject 郵件標(biāo)題 [br]' body 郵件內(nèi)容 [br]' body 郵件內(nèi)容 [br]' ishtml 是否發(fā)送html格式郵件 (true 是) [br]' htmlbody html格式郵件內(nèi)容 [br]' mailto 收件人email [br]' from 發(fā)件人email [br]' fromname 發(fā)件人姓名 [br]' smtp smtp服務(wù)器 [br]' username 郵箱用戶名 [br]' password 郵箱密碼 [br]'返回值:jmailsend="n" 發(fā)送失敗 jmailsend="y" 發(fā)送成功 [br]'~~~~~~~~~~suercool~~~~~ [br][br]'================================================= [br][br]function jmailsend(subject,body,ishtml,htmlbody,mailto,from,fromname,smtp,username,password) [br]dim jmailmsg [br]set jmailmsg=server.createobject("jmail.message") [br]jmailmsg.mailserverusername=username [br]jmailmsg.mailserverpassword=password [br][br]jmailmsg.addrecipient mailto [br]jmailmsg.from=from [br]jmailmsg.fromname=fromname [br][br]jmailmsg.charset="gb2312" [br]jmailmsg.logging=true [br]jmailmsg.silent=true [br][br]jmailmsg.subject=subject [br]jmailmsg.body=body [br]if ishtml=true then jmailmsg.htmlbody=htmlbody [br][br]if not jmailmsg.send(smtp) then [br]jmailsend="n" [br]else [br]jmailsend="y" [br]end if [br]jmailmsg.close [br]set jmailmsg=nothing [br]end function [br]%> [br][br][br][br]======================================================================================================[br]另一種:[br]<%[br] set jmail = server.createobject("jmail.smtpmail") '創(chuàng)建一個jmail對象[br] jmail.silent = true 'jmail不會拋出例外錯誤,返回的值為false跟true[br] jmail.logging = true '啟用使用日志[br] jmail.charset = "gb2312" '郵件文字的代碼為簡體中文[br] jmail.contenttype = "text/html" '郵件的格式為html的[br] jmail.serveraddress = "server address" '發(fā)送郵件的服務(wù)器[br] jmail.addrecipient email '郵件的收件人[br] jmail.sendername = "sendername" '郵件發(fā)送者的姓名[br] jmail.sender = "email address" '郵件發(fā)送者的郵件地址[br] jmail.priority = 1 '郵件的緊急程序,1 為最快,5 為最慢, 3 為默認(rèn)值[br] jmail.subject = "mail subject" '郵件的標(biāo)題[br] jmail.body = "mail body" '郵件的內(nèi)容[br] jmail.addrecipientbcc email '密件收件人的地址[br] jmail.addrecipientcc email '郵件抄送者的地址[br] jmail.execute() '執(zhí)行郵件發(fā)送[br] jmail.close '關(guān)閉郵件對象[br]%>[br]===========================================================================================================[br][br]另一種:[br][br][br]<%@ language = "vbscript" %>[br][br]<% [br]if (request.servervariables ("request_method") = "post") then[br]from = request.form("from")[br]to_ = request.form("to")[br]subject = request.form("subject")[br]body = request.form("body")[br]else[br]' assume it is get[br]from = request.querystring("from") [br]to_ = request.querystring("to") [br]subject = request.querystring("subject") [br]body = request.querystring("body") [br]end if[br][br]set objnewmail = server.createobject ("cdonts.newmail") [br]objnewmail.send from, to_, subject, body[br]set objnewmail = nothing[br]response.write "message was sent"[br]%>該文章在 2010/7/3 10:48:55 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |