LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

ASP采用Jmail发送普通附件和嵌入附件

admin
2011年9月20日 8:44 本文热度 2922
JMail发送邮件的例子都没有写如何发附件,或者没有写清如何发内嵌的附件(比如把附件图片嵌入到HTML信件里面)
郁闷到极的时候终于“柳暗花明”,噢yeah~~!!!
其实最关键的就是这句要注释掉
'JMail.ContentType = "text/html"

(为什么要发内嵌的附件图片?因为如果是img src=网上的地址,在outlook等客户端内则显示是难看的“X”,需要手动下载图片)

本例子参考了Dimac(w3JMail官方)的样例,文件地址:
C:\Program Files\Dimac\w3JMail4\Examples\ASP\htmlimage.asp
(安装了Jmail的都有)

例子代码:
<%
'*************************************************
'* *
'* Produced by Skyhe.Com *
'* *
'* Code Written by Kittow at 2005-11 *
'* http://www.skyhe.com *
'* Mail:kittow_AT_263.net *
'* *
'* *
'*************************************************

Set JMail = Server.CreateObject("JMail.Message")
'是否将信头编码成iso-8859-1字符集. 缺省是True
JMail.ISOEncodeHeaders = True

字串9


'如果JMail.silent设置为true,ErrorCode包含的是错误代码
JMail.Silent = True
'设置标题和内容编码,如果标题有中文,必须设定编码为gb2312
JMail.Charset = "gb2312"
'JMail.ContentType = "text/html" '如果发内嵌附件一定要注释掉这行,重要!
JMail.From = "web@mail.skyhe.com" ' 发送者地址
JMail.FromName = "Skyhe System" ' 发送者姓名
JMail.MailServerUserName = "web" ' 身份验证的用户名
JMail.MailServerPassword = "123456" ' 身份验证的密码
'加入新的收件人
JMail.AddRecipient "kittow@mail.skyhe.com", "Mr.Example"
'JMail.AddRecipientBCC Email '密件收件人的地址
'JMail.AddRecipientCC Email '邮件抄送者的地址
JMail.Subject = "图片测试!!!"
JMail.Body = "A nice picture if you can read HTML-mail."

'增加一个普通附件
JMail.AddAttachment(Server.MapPath("images/email.gif"))
'增加一个嵌入式附件
' The return value of AddAttachment is used as a

字串4


' reference to the image in the HTMLBody.
'contentId = JMail.AddAttachment(Server.MapPath("images/email.gif"))
Dim contentId
contentId = JMail.AddAttachment("E:\images\email.gif")

'只有HTML格式支持嵌入图片附件,我们采用HTML格式的邮件内容
' As only HTML formatted emails can contain inline images
' we use HTMLBody and appendHTML
JMail.HTMLBody = "<html><body><font color=""red"">Hi, here is a nice picture:</font><br>"
JMail.appendHTML "<img src=""cid:" & contentId & """>"
JMail.appendHTML "<br><br> good one huh?</body></html>"

'如果对方信箱不支持HTML格式邮件,我们仍需要给他一个友善的提示
' But as not all mailreaders are capable of showing HTML emails
' we will also add a standard text body
JMail.Body = "Too bad you can't read HTML-mail."
JMail.appendText " There would have been a nice picture for you" 字串6

JMail.Send( "mail.skyhe.com" )
JMail.Close()
Set JMail = Nothing
%>

该文章在 2011/9/20 8:44:05 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved