会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
代码改变世界
Cnblogs
Dashboard
Login
Home
Contact
Gallery
Subscribe
RSS
胖子的小屋
<font color=red>注:技术类文章,如无特殊说明,均为原创,转载请注明出处,谢谢!</font><a rel="nofollow noopener" href="http://sighttp.qq.com/cgi-bin/check?sigkey=9a957ab62cd923e549e6ed32b3cf259dcfe16ac2c72616e546eddceb62e41116"; target=_blank; onclick="var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=9a957ab62cd923e549e6ed32b3cf259dcfe16ac2c72616e546eddceb62e41116';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;"><img border="0" SRC='http://wpa.qq.com/pa?p=1:21814071:14' alt="胖子" title="有可能隐身"></a>
学习心得之:发送邮件(C#)
2005-03-01 22:13
胖子
阅读(
524
) 评论(
0
)
编辑
收藏
举报
参考下面的代码:
//
添加命名空间
//
using System.Web.Mail;
MailMessage Message
=
new
MailMessage();
//
收件人地址
Message.To
=
this
.txt
Receiver
.Text.Trim();
//
发件人地址
Message.From
=
this
.txtSender.Text.Trim();
//
类型(Text为纯文本)
Message.BodyFormat
=
MailFormat.Text;
//
设置邮件的优先级
Message.Priority
=
MailPriority.High;
//
主题
Message.Subject
=
"
邮件主题
"
;
//
内容
Message.Body
=
this
.txtMailContent.Text.Trim();
//
添加身份验证功能(如果需要的话)
string
username
=
"MailUserName"
;
// 发送邮件的帐号的用户名
string
password
=
"
MailPassword
"
;
// 发送邮件的帐号的密码
Message.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
"
,
"
1
"
);
Message.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendusername
"
, username);
Message.Fields.Add(
"
http://schemas.microsoft.com/cdo/configuration/sendpassword
"
, password);
// 发送邮件的服务器
SmtpMail.SmtpServer
=
"smtp.163.com"
;
//
发送邮件
SmtpMail.Send( Message );
会员力量,点亮园子希望
刷新页面
返回顶部
About