Jamil发送邮件的具体用法:
首先,我们要先下载Jamil.dll的组件,然后添加引用using jmail,然后再本机或者服务器上注册一下
将jmail.dll拷贝到服务器的system32目录下,开始-运行-cmd-输入regsvr32 jmail.dll,注册成功,然后写代码
代码如下(方法)
复制代码 代码如下:
using jmail;
protected void sendMail(String sender, String senderMail, String receiver, String subject, String content)
{
jmail.MessageClass jmMessage = new jmail.MessageClass();
//设置字符集
jmMessage.Charset = "gb2312";
//发件人邮箱地址
jmMessage.From = senderMail;
//发件人姓名
jmMessage.FromName = sender;
//设置主题
jmMessage.Subject = subject;
//设置内容
jmMessage.Body = content;
// 设置收件人邮箱
jmMessage.AddRecipient(receiver, "", "");
// 设置登陆邮箱的用户名和密码
jmMessage.MailServerUserName = "ss";
jmMessage.MailServerPassWord = "ss";
//设置smtp服务器地址
if (jmMessage.Send("smtp.163.com", false))
{
Response.Write("<script>alert('发送成功')</script>");
}
else
Response.Write("<script>alert('www.jb51.net发送失败')</script>");
}
上面就是Jmail的具体用法!
我想放一个附件如下
复制代码 代码如下:
jmail.AddAttachment(“c:autoexec.bat”)
jmail.AddAttachment(“myImage.gif”,TRUE)
结果出现如下错误
This is a multipart message in MIME format. —-NEXT_BM_AEB3968967D044DC9E208D04088C60B4 Content-Type: text/html; charset=”GB2312″ Content-Transfer-Encoding: Quoted-Printable sdfdd —-NEXT_BM_AEB3968967D044DC9E208D04088C60B4 Content-Type: application/octet-stream; name=”=?GB2312?Q?12d95384-576f-424f-bf15-f8e2397e2791=2EJPG?=” Content-Transfer-Encoding: base64 Content-Description: =?GB2312?Q?12d95384-576f-424f-bf15-f8e2397e2791=2EJPG?= Content-Disposition: inline; filename=”=?GB2312?Q?12d95384-576f-424f-bf15-f8e2397e2791=2EJPG?=” Content-ID:
网上找了解决方法:
复制代码 代码如下:
AddAttachment(FileName, isInline, ContentType) :
String为邮件添加一个文件型的附件。如果Inline 属性被设置为true,这个附件就是一个可嵌入的附件,使用addAttachment()方法可返回content id,这在发送HTML 邮件时是非常有用的。
例:
复制代码 代码如下:
jmail.AddAttachment(“c:autoexec.bat”)
jmail.AddAttachment(“myImage.gif”,TRUE)
可嵌入的附件
2.AddURLAttachment(bstrURL, bstrAttachAs, isInline, bstrAuth) : String从指定的URL 下载文件并添加为附件。第二个参数“AttachAs”用来更改添加为附件的文件的文件名,如果Inline 属性被设置为true,这个附件就是一个可嵌入的附件,使用ddAttachment()方法可返回content id,这在发送HTML 邮件时是非常有用的。最后一个参数为可选项,是当服务器需要身份验证时使用的。
例
复制代码 代码如下:
jmail.AddURLAttachment(“w3jmail4.exe”,”w3jmail4.exe”)
jmail.AddURLAttachment”w3jmail4.exe”, “w3jmail4.exe”,false, “myUserName:myPassword”)jmail.AddURLAttachment”dimaclogo.gif”,”dimaclogo.gif”,true )
测了一下,好像跟两个方法没什么关系。后来在网上有人说把Message.ContentType =”text/html”设置去掉(就是不要去设置ContentType属性),试了一下,还真发送成功了
Jmail发送邮件
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 谭咏麟.2000-魅力千禧演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 纯音入心系列纯音乐《器乐古筝》1CD[MP3][239MB]
- 纯音入心系列纯音乐《华夏民乐之古筝篇》1CD[MP3][192MB]
- 纯音入心系列纯音乐《中央民族乐团-古筝传奇》1CD[MP3][253.1MB]
- 江玲.1989-这样你才爱我,是吗?【新作有声】【WAV+CUE】
- 郭美美.2010-我是郭美美【华纳】【WAV+CUE】
- 黄心懋1991-轻忧郁【滚石】【WAV+CUE】
- 群星.2000-大地金曲世纪回顾2CD【大地】【WAV+CUE】
- 王菲.1996-浮躁(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 群星.2022-传家电视剧原声带【东阳欢娱】【FLAC分轨】
- 《摇滚教父 伍佰黄金精选 2CD》 [WAV+CUE][1GB]
- 《凤凰传奇 我从草原来》[WAV/分轨][400MB]
- 《叶倩文 真心真意过一生》[WAV+CUE][400MB]
- 潘越云.1985-世间女子(滚石25周年经典复刻版)【滚石】【WAV+CUE】
- 陈柏宇.2009-CANT.BE.HALF【SONY】【WAV+CUE】