Jmail组件发送及收邮件的asp代码 二
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
jmail实例:[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("发送成功") [br]else [br]response.write("发送失败!请重试!") [br]end if [br]'================================================= [br]'函数名:jmailsend [br]'作 用:用jmail发送邮件 [br]'参 数:subject 邮件标题 [br]' body 邮件内容 [br]' body 邮件内容 [br]' ishtml 是否发送html格式邮件 (true 是) [br]' htmlbody html格式邮件内容 [br]' mailto 收件人email [br]' from 发件人email [br]' fromname 发件人姓名 [br]' smtp smtp服务器 [br]' username 邮箱用户名 [br]' password 邮箱密码 [br]'返回值:jmailsend="n" 发送失败 jmailsend="y" 发送成功 [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") '创建一个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" '发送邮件的服务器[br] jmail.addrecipient email '邮件的收件人[br] jmail.sendername = "sendername" '邮件发送者的姓名[br] jmail.sender = "email address" '邮件发送者的邮件地址[br] jmail.priority = 1 '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值[br] jmail.subject = "mail subject" '邮件的标题[br] jmail.body = "mail body" '邮件的内容[br] jmail.addrecipientbcc email '密件收件人的地址[br] jmail.addrecipientcc email '邮件抄送者的地址[br] jmail.execute() '执行邮件发送[br] jmail.close '关闭邮件对象[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 编辑过 |
关键字查询
相关文章
正在查询... |