· 信息发布
· 广告联系
· 联系站长
动态空间 | 静态空间 | 免费域名 | 免费邮箱 | 免费论坛 | 流量统计 | 免费QQ信息 | 免费硬盘 | 中奖赚钱赠品 | 免费博客 | 免费相册 | 免费翻译 | 免费广告
免费帐号 | 免费留言本 | 免费聊天室 | 免费电话短信 | 免费游戏相关 | 免费杀毒软件 | 更多免费 | 免费影音 | 网站运营 | 网络编程 | 联盟资讯 | 网站制作
推荐资源
24小时热门资源
特别推荐
一周热门资源
信息阅读

ASP实例:实现邮件发送普通附件和嵌入附件


来源:网络 编辑:blmbolon 日期:2008-1-30 0:56:03 人气:
 
更多免费资源请关注久留免费网:http://www.96ew.com/

:久留网

网上很多关于JMail发送邮件的例子都没有写如何发附件,或者没有写清如何发内嵌的附件(比如把附件图片嵌入到HTML信件里面) 中国久留网

其实最关键的就是这句要注释掉

久留网

'JMail.ContentType = "text/html"

96ew_com

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

96ew@com

本例子参考了Dimac(w3JMail官方)的样例,文件地址:

中国久留网

C:\Program Files\Dimac\w3JMail4\Examples\ASP\htmlimage.asp 96ew^com

(安装了Jmail的都有) Www@96ew@com

例子代码: [久留网]

以下为引用的内容:

<%
Set JMail = Server.CreateObject("JMail.Message")
'是否将信头编码成iso-8859-1字符集. 缺省是True
JMail.ISOEncodeHeaders = True
'如果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" ' 身份验证的用户名

96ew_com


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." 96ew@com

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

96ew~com

'如果对方信箱不支持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" 中国久留网

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

久.留.网

 如果您发现本免费资源已过期,请点击报告错误提交过期信息,谢谢!

  • 上一篇文章:

  • 下一篇文章:

  •   关键字:AS,SP,P实,实例,例:,:实,实现,现邮,邮件,件发,发送,送普,普通,通附,附件,件和,和嵌,嵌入,入附
    久留免费网