≮海浪轻风≯

笑对人生,珍惜所有!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Jmail参考文章

Posted on 2007-03-26 12:17  ≮海浪轻风≯  阅读(222)  评论(0)    收藏  举报

ASP 可以使用JMAIL组件、CDONTS、ASPMAIL组件来发送邮件。个人只使用过jmail。
下载附件,安装完毕后即可使用(当然IIS是必备的啦~)。下面是我收集的相关文章,重复的很多。需要说明的一点就是,关于email优先级(1-5),网上说法不统一,但经过我实际操作,结论是,默认优先级(jmail.Priority=3),1的优先级最高!
=====================================================================================
asp使用jmail4.3的模块


常常要在网站中使用到JMAIL组件来发邮件。干脆就把常用的功能写成一个模块,方便调用。

把程序放到一个文件中,然后包含再call就可以了。(JMAIL4.3)

<%'警告函数
sub w_msg(message,w_to,w_link)
'message是你要弹出的警告信息,w_to=1表示自动后退一页,当w_to<>1时w_link表示要跳转的页面
if w_to="1" then
%>
<script language="javascript">
<!--
function Index(){ window.alert('<%=message%>');history.back(-1)}
Index();
-->
</script>
<%else%>
<script language="javascript">
<!--
function Index(){ window.alert('<%=message%>');window.location="<%=w_link%>"}
Index();
-->
</script>
<%end if
end sub%>
<%
sub sendmail(mailtitle,mailtext,mailaddress,mailcc,mailbcc,attachment,mailserver)
if mailtitle="" then
mailtitle="系统测试邮件"
end if
if mailtext="" then
mailtext="Just a test"
end if
if mailaddress="" then
call w_msg("邮件地址不能为空","1","")
end if
if mailserver="" then
mailserver="smtp.163.com"
end if
set msg=server.createobject("JMail.Message")
msg.silent = true
msg.logging = true
msg.Charset="GB2312"
msg.ContentType = "text/html"
msg.MailServerUserName="yourusername"
msg.MailServerPassword="yourpassword"
msg.From="youremail"
msg.FromName="dorryyang"
mailaddress_s=split(mailaddress,",") ' 邮件地址用,格开
for i=0 to ubound(mailaddress_s)
msg.AddRecipient trim(mailaddress_s(i))
next
if mailcc<>"" then
mailcc_s=split(mailcc,",")
for i=0 to ubound(mailcc_s)
msg.AddRecipientCC trim(mailcc_s(i))
next
end if
if mailbcc<>"" then
mailbcc_s=split(mailbcc,",")
for i=0 to ubound(mailbcc_s)
msg.AddRecipientBCC trim(mailbcc_s(i))
next
end if
if attachment<>"" then
msg.AddAttachment(attachment) 'attachment写附件地址
end if
msg.Subject=mailtitle
msg.HTMLBody=mailtext
msg.Send(mailserver)
msg.close
set msg=nothing
call w_msg("发送成功","1","")
end sub
%>
=====================================================================================

该段代码涉及到JMail v4.3的大部分常用方法。
包括邮件基本信息、身份验证、附件等。无需很多的修改就可以使用,也可以改成函数或过程。

<%
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")

JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True

' 发送者信息(可用变量方式赋值)
JMail.From = "jiaz@21cn.com" ' 发送者地址
JMail.FromName = "D.J." ' 发送者姓名
JMail.Subject = "您在炫网资讯的歌词快递(请将编码设为简体中文(gb2312))" ' 邮件主题

' 身份验证
JMail.MailServerUserName = "user" ' 身份验证的用户名
JMail.MailServerPassword = "password" ' 身份验证的密码

' 设置优先级,范围从1到5,1的优先级越高,3为普通
JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

' 加入一个收件人【变量email:收件人地址】可以同一语句重复加入多个
JMail.AddRecipient(email)

' 加入附件【变量filename:附件文件的绝对地址,确保用户IUSR_????有访问的权限】
' 【参数设置是(True)否(False)为Inline方式】
contentId = JMail.AddAttachment (filename, True)

' 邮件主体(HTML(注意信件内链接附件的方式))
JMail.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""><style type=text/css>A:link { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000}A:visited {FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #666666}A:hover {COLOR: #ff6600; FONT-SIZE: 9pt; TEXT-DECORATION: underline}BODY {FONT-SIZE: 9pt} --></style></head><body bgcolor=""#FFFFFF"" text=""#666666"" leftmargin=""0"" topmargin=""30"" link=""#FF9900""><center>点击这里<a href=' cid:" & contentId & "' >[附件文件]</a>将文件保存</center></body></html>"

' 邮件主体(文本部分)
JMail.Body = "我们的邮件采用了HTML格式,但是您的邮件查看软件可能不支持。您可以访问以下地址来查看:http://music.liuxuan.com"

' 发送【调用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send("user:password@smtp.21cn.com")

' 关闭并清除对象
JMail.Close()
Set JMail = Nothing
%>
=====================================================================================
其余参考地址:(看过一遍,忘了再看)

http://zhidao.baidu.com/question/5374049.html
http://www.it055.com/it055_infos/net_programs/asp/266_page1.htm




http://www.wzsky.net/html/article/asp/asp2/14040.html













http://hakaosans.yculblog.com/post.581113.html
http://www.rwrj.cn/Article/Class1/200402/20040220222235.html


http://study.zhupao.com/infoview/Article_16775.html

http://zhidao.baidu.com/question/5291335.html

http://www.home123.com.cn/FAQ/asp/1.html (这上面是关于jmail的一些常见问题。)
http://www.chinaphp.com/chinese/asp/1025538485.html (jmail)
http://www.mobanku.com/file/asp/00035.asp (cdonts)
http://www.zwwr.com/article/show.asp?id=20818 (关于发送附件)


 
附件下载:Jmail参考手册2本      w3jmail4_4组件