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.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:
2.AddURLAttachment(bstrURL, bstrAttachAs, isInline, bstrAuth) : String从指定的URL 下载文件并添加为附件。第二个参数“AttachAs”用来更改添加为附件的文件的文件名,如果Inline 属性被设置为true,这个附件就是一个可嵌入的附件,使用ddAttachment()方法可返回content id,这在发送HTML 邮件时是非常有用的。最后一个参数为可选项,是当服务器需要身份验证时使用的。
测了一下,好像跟两个方法没什么关系。后来在网上有人说把Message.ContentType =”text/html”设置去掉(就是不要去设置ContentType属性),试了一下,还真发送成功了