try
{
mailmessage mm = new mailmessage();
mailaddress fromma = new mailaddress("xxxx@qq.com");
mailaddress toma = new mailaddress("mmmmmmm@qq.com", null);
mm.from = fromma;
//收件人
mm.to.add("mmmmmm@qq.com");
//邮箱标题
mm.subject = "hello dear:";
mm.isbodyhtml = true;
//邮件内容
mm.body = "你好mr流星!";
//内容的编码格式
mm.bodyencoding = system.text.encoding.utf8;
//mm.replyto = toma;
//mm.sender =fromma;
//mm.isbodyhtml = false;
mm.deliverynotificationoptions = deliverynotificationoptions.onsuccess;
mm.cc.add(toma);
smtpclient sc = new smtpclient();
networkcredential nc = new networkcredential();
nc.username = "xxxxx@qq.com";//你的邮箱地址
nc.password = "zzzzz";//你的邮箱密码,这里的密码是xxxxx@qq.com邮箱的密码,特别说明下~
sc.usedefaultcredentials = true;
sc.deliverymethod = smtpdeliverymethod.network;
sc.credentials = nc;
//如果这里报mail from address must be same as authorization user这个错误,是你的qq邮箱没有开启smtp,
//到你自己的邮箱设置一下就可以啦!在帐户下面,如果是163邮箱的话,下面该成smtp.163.com
sc.host = "smtp.qq.com";
sc.send(mm);
}
catch (exception ex)
{
throw new exception(ex.message);
}
这个是我用我的2个qq测试成功了的,有问题希望各位指正~~
更多c#调用qq邮箱smtp发送邮件修改版代码。
【相关推荐】
1. 详细介绍python使用smtp发送邮件实例
2. python 使用smtp发送邮件的代码小结
3. 分享python实现smtp发送邮件图文实例
4. python使用smtp发送邮件
5. php smtp发送邮件
6. python smtp邮件模块详解
7. python smtplib模块发送ssl/tls安全邮件实例