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

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - 君

50口诀让你轻松记四六级单词 苦瓜炒蛋 随笔 将货币数字描述转化成中文描述 - 君 - 博客园 年旦前 经历一劫 2007-12-16 随缘也 留脚 一篇不错的文章 .net修改网络配置,如IP,DNS等 2007-2-3 2006-12-23 .NET中获取系统硬件信息 网站宣传 用C#播放声音文件 DotNetMagic做应用程序界面(类似office2003风格) Grove——.NET中的ORM实现(转载,学习...........)
.net写发送邮件工具
· 2007-02-09 · via 博客园 - 君

具体发送邮件的命名空间System.Net.Mail下有很多方法,下面是复制的代码;
具体的界面自己画一下就可以了,应该看的懂,具体代码如下:

 1private void button1_Click(object sender, EventArgs e)
 2
 3        {//发送
 4
 5            string strRecieveEMail = txtRecieveEMail.Text.Trim();
 6
 7            string strSendEmail = txtSendEMail.Text.Trim();
 8
 9            string strSubject = txtSubject.Text.Trim();
10
11            string strBody = txtBody.Text.Trim();
12
13 
14
15            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
16
17            msg.To.Add(strRecieveEMail);
18
19 
20
21            //System.Net.Mail.MailAddress mAdd = 
22
23 
24
25            if(txtAttachment.Text.Trim().Length > 0)
26
27            {
28
29                string FileName = txtAttachment.Text.Trim();
30
31                System.Net.Mail.Attachment pAttachment = new Attachment(FileName);
32
33                msg.Attachments.Add(pAttachment);
34
35            }

36
37            
38
39            msg.From = new MailAddress(strSendEmail, strSendEmail, System.Text.Encoding.UTF8);;
40
41            /* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
42
43            msg.Subject = strSubject;//邮件标题             
44
45            msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码 
46
47            msg.Body = strBody;//邮件内容 
48
49            msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码 
50
51            msg.IsBodyHtml = false;//是否是HTML邮件 
52
53            msg.Priority = MailPriority.High;//邮件优先级 
54
55 
56
57 
58
59            SmtpClient client = new SmtpClient();
60
61            client.Host = txtSmtp.Text.Trim();//这个非常重要,为邮件服务器设置
62
63 
64
65            object userState = msg;
66
67            try
68
69            {
70
71                client.SendAsync(msg, userState);    //简单一点儿可以client.Send(msg); 
72
73                MessageBox.Show("成功发送到" + strRecieveEMail + "邮箱");
74
75            }

76
77            catch (System.Net.Mail.SmtpException ex)
78
79            {
80
81                MessageBox.Show(ex.Message, "发送邮件出错");
82
83            }

84
85        }

86