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

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

博客园 - E.L.---黑者如斯夫,不舍昼夜......

SAP B1 ADDON 开发 ScribeFire Blog Editor 不错 什么是信用证L/C? tiptop成本计算逻辑axcp500 C#小闹钟 简单实用 [整理]c#简单调用DELPHI DLL封装窗体 [原创]简单防范ARP攻击,突破(P2P终结者)下载控制。 [转贴]gOS 3 Gadgets.Linx for the rest of us [收藏]NSIS Quick Start [转贴] [原创]關于SAP Business One三角貿易的程序設計(拋轉其他資料庫部分) Nik Og Jay 又一经典 "En Dag Tilbage" Nik Og Jay Elsker Hende Mere---”难道是北欧凛冽的空气把一切都洗得一尘不染……清新的Rap“ LeAnn Rimes - Life Goes On .Net Delegates: A C# bedtime story[转贴] 一首歌,一支烟,一个人... [原创]关于SAP Business One 中LinkButton.LinkedObject=lf_UserDefinedObject报错解决方案 视频:沙特向中国捐赠5000万美元现金 [原创]周末赶工SAP DI实现库存重估 圈圈<见龙卸甲>
gmail发送邮件 C#实现(测试OK) - E.L.---黑者如斯夫,不舍昼夜...... - 博客园
E.L.---黑者如斯夫 · 2010-01-31 · via 博客园 - E.L.---黑者如斯夫,不舍昼夜......

        static string strHost = string.Empty;
        
static string strAccount = string.Empty;
        
static string strPwd = string.Empty;
        
static string strFrom = string.Empty;

代码

public bool sendMail(string to, string title, string content)
        {
           
             strHost 
= "smtp.gmail.com";   //STMP服务器地址
             strAccount = "lane.liang@gmail.com";       //SMTP服务帐号
             strPwd = "密码";       //SMTP服务密码
             strFrom = "lane.liang@gmail.com";  //发送方邮件地址
         
            SmtpClient _smtpClient 
= new SmtpClient();
            _smtpClient.Host 
= strHost; ;//指定SMTP服务器
            _smtpClient.Port = 587;
            _smtpClient.EnableSsl 
= true;
            _smtpClient.UseDefaultCredentials 
= false;
            
            _smtpClient.Credentials 
= new System.Net.NetworkCredential(strAccount, strPwd);//用户名和密码
            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
            

            MailMessage _mailMessage 

= new MailMessage(strFrom, to);
            
//_mailMessage.CC = cc;
           
//_mailMessage.AlternateViews
            _mailMessage.Subject = title;//主题
            _mailMessage.Body = content;//内容
            _mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
            _mailMessage.IsBodyHtml = true;//设置为HTML格式
            _mailMessage.Priority = MailPriority.High;//优先级
            
             
try
            {
                _smtpClient.Send(_mailMessage);
                
return true;
            }
            
catch
            {
                
return false;
            }
        }

调用方法:bool i = oMailSender.sendMail("目标邮件地址", "这是一封测试邮件", "这是一封测试邮件的正文内容");