public static bool send(string strMto, string strMfrom, string strFname, string strSubject, string strHtml)
{
jmail.Message jmail = new jmail.Message();
string subject = strSubject;
string body = strHtml;
string fromemail = strMfrom;
jmail.FromName = strFname;//发送人姓名
string toemail = strMto;
//silent属性:如果设置为true,jmail不会抛出例外错误. jmail. send( () 会根据操作结果返回true或false
jmail.Silent = false;
//jmail创建的日志,前提loging属性设置为true
jmail.Logging = true;
//字符集,缺省为"us-ascii"
jmail.Charset = "gb2312";
//jmail.ContentTransferEncoding = "base64";
//jmail.Encoding = "base64";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以html格式发送邮件, 改为"text/html"即可。
jmail.ContentType = "text/html";
//添加收件人
jmail.AddRecipient(toemail, "", "");
jmail.From = fromemail;
//发件人邮件用户名
jmail.MailServerUserName = "******";
//发件人邮件密码
jmail.MailServerPassWord = "******";
//设置邮件标题
jmail.Subject = subject;
//邮件添加附件,(多附件的话,可以再加一条jmail.addattachment( "c:\\test.jpg",true,null);)就可以搞定了。〔注〕:加了附件,讲把上面的jmail.contenttype="text/html";删掉。否则会在邮件里出现乱码。
//jmail.AddAttachment( "c:\\test.jpg",true,null);
//邮件内容
jmail.Body = body;
//jmail.Silent = true;
//jmail发送的方法
bool result = jmail.Send("smtp.qq.com", false);
jmail.Close();
return result;
}
代码如上边错误代码 0x8000ffffbool result = jmail.Send("smtp.qq.com", false);这句报错请不要拿网上的代码复制粘贴 谢谢。提示是:The message was undeliverable. All servers failed to receive the message
{
jmail.Message jmail = new jmail.Message();
string subject = strSubject;
string body = strHtml;
string fromemail = strMfrom;
jmail.FromName = strFname;//发送人姓名
string toemail = strMto;
//silent属性:如果设置为true,jmail不会抛出例外错误. jmail. send( () 会根据操作结果返回true或false
jmail.Silent = false;
//jmail创建的日志,前提loging属性设置为true
jmail.Logging = true;
//字符集,缺省为"us-ascii"
jmail.Charset = "gb2312";
//jmail.ContentTransferEncoding = "base64";
//jmail.Encoding = "base64";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以html格式发送邮件, 改为"text/html"即可。
jmail.ContentType = "text/html";
//添加收件人
jmail.AddRecipient(toemail, "", "");
jmail.From = fromemail;
//发件人邮件用户名
jmail.MailServerUserName = "******";
//发件人邮件密码
jmail.MailServerPassWord = "******";
//设置邮件标题
jmail.Subject = subject;
//邮件添加附件,(多附件的话,可以再加一条jmail.addattachment( "c:\\test.jpg",true,null);)就可以搞定了。〔注〕:加了附件,讲把上面的jmail.contenttype="text/html";删掉。否则会在邮件里出现乱码。
//jmail.AddAttachment( "c:\\test.jpg",true,null);
//邮件内容
jmail.Body = body;
//jmail.Silent = true;
//jmail发送的方法
bool result = jmail.Send("smtp.qq.com", false);
jmail.Close();
return result;
}
代码如上边错误代码 0x8000ffffbool result = jmail.Send("smtp.qq.com", false);这句报错请不要拿网上的代码复制粘贴 谢谢。提示是:The message was undeliverable. All servers failed to receive the message
解决方案 »
- pictureBox控件摄像后,通过“浏览本地图片”无法显示
- 如何实现局域网之间的文件上传下载
- datagridview单元格显示
- WebRequest GetResponse()方法下载exe文件时返回404错误
- 不用SQL Server Management Studio怎么备份数据库?
- 如何能把一个dataset中的不同datatable在一个gridview中显示出来
- C# Datagridview
- 自定控件接受不了键盘事件
- 请问:在C#中如何获得一个进程的父进程或者子进程?谢谢!
- 请高手帮忙,自定义控件在Design Time 如何修改控件大小,up有分。
- 数据源用dataTable还是泛型集合好?
- C# 如何实现图像编辑工具条??
public static void SendEmail(string from, string to, string cc, string subject, string body, string attachment)
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(from, to, subject, body);
mail.CC.Add(new MailAddress(cc));
mail.Attachments.Add(new Attachment(attachment));
mail.IsBodyHtml = false; System.Net.Mail.SmtpClient send = new System.Net.Mail.SmtpClient("smtp.gmail.com");
send.Port = 587;// gmail;
send.EnableSsl = true;
send.UseDefaultCredentials = false;
send.Credentials = new NetworkCredential("username", "password");
send.Send(mail);
}
{
bool isNo = false;
jmail.Message jmessage = new jmail.MessageClass(); jmessage.Charset = "GB2312";
jmessage.From = "[email protected]";//发送邮件人的邮箱
jmessage.FromName = "第一英才";//发送邮件人的用户名
jmessage.ReplyTo = "[email protected]";//跟上边一样的
jmessage.ContentType = "text/html";
jmessage.Charset = "GB2312";
jmessage.ContentTransferEncoding = "base64";
jmessage.Encoding = "base64";
jmessage.Subject = MailTitle;//标题
jmessage.AddRecipient(EmailAddress, RecipientName, PGPKey);//收件人
jmessage.Body = strHtml;//内容
jmessage.MailServerUserName = "[email protected]";//发件人用户名
jmessage.MailServerPassWord = "123456a";//发件人用户密码
if(jmessage.Send("smtp.qq.com", false))// smtp
{
isNo = true;
}else
{
isNo = true;
}
//Response.Write("email sent successfully!");
jmessage.Close();//注意这里,一定要关闭连接 否则邮件发不出去
return isNo;
}