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

推荐订阅源

Latest news
Latest news
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
L
LINUX DO - 热门话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
V
V2EX
博客园 - 司徒正美
B
Blog RSS Feed
AWS News Blog
AWS News Blog
MyScale Blog
MyScale Blog
Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
Last Week in AI
Last Week in AI
NISL@THU
NISL@THU
博客园 - Franky
P
Proofpoint News Feed
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
S
Schneier on Security
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
G
GRAHAM CLULEY
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
WordPress大学
WordPress大学
The Hacker News
The Hacker News
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Microsoft Azure Blog
Microsoft Azure Blog
T
The Exploit Database - CXSecurity.com
Engineering at Meta
Engineering at Meta
罗磊的独立博客
T
The Blog of Author Tim Ferriss
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
K
Kaspersky official blog
SecWiki News
SecWiki News
云风的 BLOG
云风的 BLOG
美团技术团队
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
B
Blog
S
Security Affairs

博客园 - semye

input+select(multiple)实现下拉框输入值 简单的js分页脚本 - semye - 博客园 请问做个类似这样的网站多少钱 省份和城市 - semye - 博客园 客户端取用户控件中服务器控件的标识 VS2003调试很慢 enctype="multipart/form-data" 群发邮件太慢了! SQL SERVER “数组参数” WEB水晶报表部署笔记 写程序解智力题,help!!! 低级错误是怎样“炼”成的? SQL语句区分大小写问题 JS事件大全 WinForm动态添加控件及其事件 WinForm程序实现滚动字幕与背景音乐 公历转换为农历 简单水晶报表程序与安装部署文件制作 导数程序
发送邮件 - semye - 博客园
semye · 2007-04-10 · via 博客园 - semye

 1        private void SentEmail(string email,string name,string UserAccount)
 2        {
 3            BLL.MailSender ms = new MailSender();
 4            ms.Body = "尊敬的"+name+":<br><br>"+"&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp欢迎使用********!(<a href='http://*********.com'>http://*********</a>)<br><br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp您注册的账号现已开通!登陆名:"
 5                +UserAccount+"";
 6            ms.From = "********";
 7            ms.Password = "********";
 8            ms.Port = "25";
 9            ms.Server = "*********";
10            ms.Subject = "账号开通信息";
11            ms.To = email;
12            ms.UserName = "*********";
13            ms.SendMail();
14            
15        }

16

  1using System;
  2using System.Web.Mail; 
  3using CDO; 
  4namespace BLL
  5{
  6    /// <summary>
  7    /// MailSender 的摘要说明。
  8    /// </summary>

  9
 10    public class MailSender 
 11    
 12
 13        private string server = ""
 14        /// <summary>
 15        /// 
 16        /// </summary>

 17        public string Server 
 18        
 19            get 
 20            {
 21                return server;
 22            }
 
 23            set 
 24            
 25                if (value != server) server = value;
 26            }
 
 27        }
        
 28
 29        private string port = ""
 30        /// <summary>
 31        /// 
 32        /// </summary>

 33        public string Port 
 34        
 35            get 
 36            {
 37                return port;
 38            }
 
 39            set 
 40            
 41                if (value != port) port = value;
 42            }
 
 43        }
        
 44
 45        private string userName = ""
 46        /// <summary> 
 47        /// 用户名 [如果需要身份验证的话] 
 48        /// </summary> 

 49        public string UserName 
 50        
 51            get
 52            {
 53                return userName;
 54            }
 
 55            set 
 56            
 57                if (value != userName)
 58                    userName = value;
 59            }
 
 60        }
         
 61
 62        private string password = ""
 63        /// <summary> 
 64        /// 密码 [如果需要身份验证的话] 
 65        /// </summary> 

 66        public string Password 
 67        
 68            get 
 69            
 70                return password;
 71            }
 
 72            set
 73            
 74                if (value != password)
 75                    password = value;
 76            }
 
 77        }

 78                
 79        private string from = ""
 80        /// <summary> 
 81        /// 发件人地址 
 82        /// </summary> 

 83        public string From 
 84        
 85            get
 86            
 87                return from;
 88            }
 
 89            set
 90            
 91                if (value != from) 
 92                    from = value;
 93            }
 
 94        }
 
 95
 96        private string to = ""
 97        /// <summary> 
 98        /// 收件人地址 
 99        /// </summary> 

100        public string To 
101        
102            get
103            {
104                return to;
105            }
 
106            set
107            {
108                if (value != to) 
109                    to = value;
110            }
 
111        }

112        
113        private string subject = ""
114        /// <summary> 
115        /// 邮件的主题 
116        /// </summary> 

117        public string Subject 
118        
119            get
120            {
121                return subject; 
122            }
 
123            set 
124            
125                if (value != subject) 
126                    subject = value; 
127            }
 
128        }
 
129        
130
131        private string body = ""
132        /// <summary> 
133        /// 邮件正文 
134        /// </summary> 

135        public string Body 
136        
137            get
138            {
139                return body;
140            }
 
141            set 
142            {
143                if (value != body)
144                    body = value;
145            }
 
146        }

147        
148
149        private string htmlBody = "";
150        /// <summary> 
151        /// 超文本格式的邮件正文 
152        /// </summary> 

153        public string HtmlBody 
154        
155            get
156            
157                return htmlBody;
158            }
 
159            set 
160            {
161                if (value != htmlBody)
162                    htmlBody = value;
163            }
 
164        }
 
165        
166        private bool isHtml = false
167        /// <summary> 
168        /// 是否是html格式的邮件 
169        /// </summary> 

170        public bool IsHtml 
171        
172            get 
173            
174                return isHtml; 
175            }
 
176            set
177            {
178                if (value != isHtml)
179                    isHtml = value; 
180            }
 
181        }

182        
183
184        public void SendMail () 
185        
186            MailMessage msg = new MailMessage();
187
188            msg.From = from;
189            msg.To = to;
190            msg.Subject = subject;
191            msg.Body = body;
192            msg.BodyFormat = MailFormat.Html;
193            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1" ); 
194            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",userName);
195            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
196        
197            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", port);
198        
199            //msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "1");
200            
201
202            SmtpMail.SmtpServer = server;
203            SmtpMail.Send(msg);
204
205
206
207        }
 
208    }

209}

210