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

推荐订阅源

P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
Forbes - Security
Forbes - Security
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
About on SuperTechFans
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
雷峰网
雷峰网
腾讯CDC
P
Proofpoint News Feed
S
Schneier on Security
S
Secure Thoughts
V
Visual Studio Blog
Help Net Security
Help Net Security
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Privacy International News Feed
SecWiki News
SecWiki News
S
SegmentFault 最新的问题
T
Threatpost
小众软件
小众软件
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
T
Tailwind CSS Blog
I
Intezer
C
CERT Recently Published Vulnerability Notes
U
Unit 42
V
V2EX
Cyberwarzone
Cyberwarzone
Recorded Future
Recorded Future
O
OpenAI News
Project Zero
Project Zero
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
V2EX - 技术
V2EX - 技术
博客园 - 叶小钗
S
Securelist
A
Arctic Wolf
The Cloudflare Blog
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
博客园 - Franky

博客园 - changchang

SQL中的join用法(zt) 远程桌面 Web 连接 RTM、RC、CTP版本的含义(ZT) Culture Name(转) - changchang - 博客园 MPEG、RM、WMV电影文件格式转换指南(转) PDF文件相关下载 Form验证(转) .net下枚举的用法 - changchang - 博客园 .net操作文件的基本方法总结 - changchang - 博客园 JavaScript动态的为元素添加事件 dotnet下Request对象获取客户端数据的方式比较(Request.Params) - changchang - 博客园 (转载)一个大家不常用到,却很有用的页面间传值方法(Context.Handler) - changchang - 博客园 CuteEditor学习总结技巧 Javascript图片幻灯片的实现 Window下配置SVN服务器与客户端 Javascript访问html页面的控件 深入理解.net的事件与委托机制 asp.net控件本质 google map简单实现
asp.net 2.0发送和接收邮件总结
changchang · 2007-09-25 · via 博客园 - changchang

总结:.用asp.net 2.0发送邮件非常的方便,只需要用using System.Net.Mail命名空间下的类就可以完成发送邮件的功能,发送邮件的服务器可以有以下几种情况:
1.本地的smtp服务器
2.网络上的smtp服务器(smtp.163.com等)
以下是我测试发送邮件的范例,基本上都考虑到的所有的情况,如果还有什么没有考虑到的请给我留言,我接续完善其功能.
1.新建一网站名字叫SentEmailText.
2.添加一个新的页面default.aspx
代码如下:

<form id="Form1" runat="server" method="post">
     
<div id="content">
                 
<div id="msg">
                    
<div id="msg_title">Send Email Test</div>
                    
<div id="msg_prompt"></div>
                    
<asp:ValidationSummary id="msg_alarm" runat="server"></asp:ValidationSummary>
                
</div>
                
<div id="form">
                     
<div>
                        
<label for="SmtpServerText">Sever name:</label>
                        
<input type="text"  id="SmtpServerText" name="SmtpServerText" runat="server" />
                    
</div>
                     
<div>
                        
<label for="SmtpServerPort">Sever Port:</label>
                        
<input type="text" id="SmtpServerPort"  name="SmtpServerPort" runat="server" />
                    
</div>
                     
<div>
                        
<label for="UserName">User Name:</label>
                        
<input type="text"  name="UserName" id="UserName" runat="server" />
                    
</div>
                     
<div>
                        
<label for="Pwd">Pwd:</label>
                        
<input type="text"  name="Pwd" runat="server" id="Pwd" />
                    
</div>
                     
<div>
                        
<label for="FromAddress">From Address:</label>
                        
<input type="text"  name="FromAddress" runat="server" id="FromAddress" />
                    
</div>
                     
<div>
                        
<label for="SendAddress">Send Address:</label>
                        
<input type="text"  name="SendAddress" runat="server" id="SendAddress" />
                    
</div>
                     
<div>
                        
<label for="attachment">Attachment:</label>
                        
<input type="file" runat="server" name="attachment" id="attachment" />
                    
</div>
                     
<div>
                        
<label for="txtSubject">Email Subject:</label>
                        
<input type="text"  name="txtSubject" runat="server" id="txtSubject" />
                    
</div>
                    
<div>
                        
<label for="txtBody">Email Body:</label>
                        
<textarea name="txtBody" runat="server" rows="10" cols="50" id="txtBody"></textarea>
                    
</div>
                    
<div>
                        
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        
<input type="submit" value="Send Email" class="prim" id="btnSend" runat="server" onserverclick="btnSend_ServerClick" />
                    
</div>
                
</div>
       
</div>
    
</form>

3.新建一个style的文件夹,添加样式页面,主要功能是表单的对齐样式,比较通用的设置(见附件)
4.添加一个mail的类文件,注意用于发送邮件考虑的几种情况(见附件)

using System;
using System.Text; 
using System.Net.Mail;
using System.Net.Sockets;
using System.IO;
public class Mail
{
  
"Custom var"

  
"Property"

  
"OverLoad"

  
"Send Emial including groups and attachment"

  
/// <summary>
  
/// Received Email
  
/// </summary>

    public void ReseiveMail()
    
{
        
string ServerHost = "pop3."+this._Host ;
        TcpClient tcp 
= new TcpClient(ServerHost, 110);
        NetworkStream ns 
= tcp.GetStream();
        StreamReader sr 
= new StreamReader(ns);
        StreamWriter sw 
= new StreamWriter(ns);
     }

 }

5.页面调用方式参见附件
6.附件下载附件(源代码下载)