惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 杨林

IIs一些配置 扩大传输限制 exchange file 关于VS2005 无法使用切换到设计视图的解决方法 使用ASP.Net Forms模式实现WebService身份验证 web导出excel格式问题 Form身份验证 - 杨林 - 博客园 在ASP.NET 2.0中使用Membership sql T 设计模式之状态模式 sqlserver2005学习笔记 - 杨林 共享内存进程之间 - 杨林 ComparaCarAdapter sql 利用索引优化性能 - 杨林 SQL 2005新增的几个函数之学习 - 杨林 Thread pool - 杨林 web service web service - 杨林 多线程分析 js Function.call
SendEmail - 杨林 - 博客园
杨林 · 2008-04-12 · via 博客园 - 杨林

///   <summary>
               
///   发送邮件
               
///   </summary>
               
///   <param   name= "strSmtpServer "> smtp地址 </param>
               
///   <param   name= "UserName "> 用户名 </param>
               
///   <param   name= "Password "> 密码 </param>
               
///   <param   name= "strFrom "> 发信人地址 </param>
               
///   <param   name= "strto "> 收信人地址 </param>
               
///   <param   name= "strSubject "> 邮件标题 </param>
               
///   <param   name= "strBody "> 邮件正文 </param>
                public   static   void   SendMail(string   strSmtpServer,   string   UserName,   string   Password,   string   strFrom,   string   strto,   string   strSubject,   string   strBody,   string   strFileName)
                {
                       
//生成一个   使用SMTP发送邮件的客户端对象
                        System.Net.Mail.SmtpClient   client   =   new   System.Net.Mail.SmtpClient(strSmtpServer); //表示以当前登录用户的默认凭据进行身份验证
                        client.UseDefaultCredentials   =   true; //包含用户名和密码
                        client.Credentials   =   new   System.Net.NetworkCredential(UserName,   Password); //指定如何发送电子邮件。
                         
//Network                                             电子邮件通过网络发送到   SMTP   服务器。    
                         
//PickupDirectoryFromIis               将电子邮件复制到挑选目录,然后通过本地   Internet   信息服务   (IIS)   传送。    
                         
//SpecifiedPickupDirectory           将电子邮件复制到   SmtpClient.PickupDirectoryLocation   属性指定的目录,然后由外部应用程序传送。    

                        client.DeliveryMethod  
=   System.Net.Mail.SmtpDeliveryMethod.Network; //建立邮件对象  
                        System.Net.Mail.MailMessage   message   =   new   System.Net.Mail.MailMessage(strFrom,   strto,   strSubject,strBody);
                       
                       
//定义邮件正文,主题的编码方式
                        message.BodyEncoding   =   System.Text.Encoding.GetEncoding( "gb2312 ");
                        message.SubjectEncoding  
=   System.Text.Encoding.GetEncoding( "gb2312 ");
                     
                       
//获取或设置一个值,该值指示电子邮件正文是否为   HTML。  
                        message.IsBodyHtml   =   false;
                       
                       
//指定邮件优先级
         
                        message.Priority  
=   System.Net.Mail.MailPriority.Normal; //添加附件
                       
//System.Web.Mail.MailAttachment   mailAttachment=new   System.Web.Mail.MailAttachment(@ "f:/baihe.txt ");  
                        if   (strFileName   !=   " "   &&   strFileName   !=   null)
                        {
                                Attachment   data  
=   new   Attachment(strFileName);
                                message.Attachments.Add(data);
                        }
                   
                       
                       
//发件人身份验证,否则163   发不了
                        client.Credentials   =     new   System.Net.NetworkCredential(strFrom,   Password); //发送
                        client.Send(message);
                }
        }