亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? form1.cs

?? 本文件是中國水利水電出版社出版的一《案例開發》配套的光盤
?? CS
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net ;
using System.IO;
using System.Net.Sockets ;
using System.Text ;
namespace MailPOP3
{
	/// <summary>
	/// Form1 的摘要說明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.TextBox servername;
		private System.Windows.Forms.TextBox mailport;
		private System.Windows.Forms.TextBox password;
		private System.Windows.Forms.TextBox username;
		private System.Windows.Forms.Button receive;
		private System.Windows.Forms.RichTextBox richTextBox1;
		private System.Windows.Forms.RichTextBox richTextBox2;
		/// <summary>
		/// 必需的設計器變量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗體設計器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
			//
		}

		/// <summary>
		/// 清理所有正在使用的資源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗體設計器生成的代碼
		/// <summary>
		/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
		/// 此方法的內容。
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label1 = new System.Windows.Forms.Label();
			this.servername = new System.Windows.Forms.TextBox();
			this.mailport = new System.Windows.Forms.TextBox();
			this.password = new System.Windows.Forms.TextBox();
			this.username = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.receive = new System.Windows.Forms.Button();
			this.richTextBox1 = new System.Windows.Forms.RichTextBox();
			this.richTextBox2 = new System.Windows.Forms.RichTextBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.servername);
			this.groupBox1.Controls.Add(this.mailport);
			this.groupBox1.Controls.Add(this.password);
			this.groupBox1.Controls.Add(this.username);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Location = new System.Drawing.Point(4, 4);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(490, 82);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "接收郵件服務器設置";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(10, 26);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "服務器名:";
			// 
			// servername
			// 
			this.servername.Location = new System.Drawing.Point(76, 22);
			this.servername.Name = "servername";
			this.servername.Size = new System.Drawing.Size(174, 21);
			this.servername.TabIndex = 0;
			this.servername.Text = "";
			// 
			// mailport
			// 
			this.mailport.Location = new System.Drawing.Point(76, 52);
			this.mailport.Name = "mailport";
			this.mailport.Size = new System.Drawing.Size(174, 21);
			this.mailport.TabIndex = 0;
			this.mailport.Text = "";
			// 
			// password
			// 
			this.password.Location = new System.Drawing.Point(306, 52);
			this.password.Name = "password";
			this.password.Size = new System.Drawing.Size(174, 21);
			this.password.TabIndex = 0;
			this.password.Text = "";
			// 
			// username
			// 
			this.username.Location = new System.Drawing.Point(306, 22);
			this.username.Name = "username";
			this.username.Size = new System.Drawing.Size(174, 21);
			this.username.TabIndex = 0;
			this.username.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(38, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(36, 14);
			this.label2.TabIndex = 1;
			this.label2.Text = "端口:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(260, 26);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 14);
			this.label3.TabIndex = 1;
			this.label3.Text = "用戶名:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(272, 56);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(36, 16);
			this.label4.TabIndex = 1;
			this.label4.Text = "密碼:";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.richTextBox1);
			this.groupBox2.Location = new System.Drawing.Point(4, 90);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(562, 100);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "郵件名稱";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.richTextBox2);
			this.groupBox3.Location = new System.Drawing.Point(2, 194);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(564, 224);
			this.groupBox3.TabIndex = 3;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "郵件內容";
			// 
			// receive
			// 
			this.receive.Location = new System.Drawing.Point(498, 30);
			this.receive.Name = "receive";
			this.receive.Size = new System.Drawing.Size(64, 23);
			this.receive.TabIndex = 4;
			this.receive.Text = "接收郵件";
			this.receive.Click += new System.EventHandler(this.receive_Click);
			// 
			// richTextBox1
			// 
			this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.richTextBox1.Location = new System.Drawing.Point(3, 17);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(556, 80);
			this.richTextBox1.TabIndex = 1;
			this.richTextBox1.Text = "";
			// 
			// richTextBox2
			// 
			this.richTextBox2.Dock = System.Windows.Forms.DockStyle.Fill;
			this.richTextBox2.Location = new System.Drawing.Point(3, 17);
			this.richTextBox2.Name = "richTextBox2";
			this.richTextBox2.Size = new System.Drawing.Size(558, 204);
			this.richTextBox2.TabIndex = 0;
			this.richTextBox2.Text = "";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(568, 424);
			this.Controls.Add(this.receive);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.MaximizeBox = false;
			this.Name = "Form1";
			this.Text = "郵件接收";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 應用程序的主入口點。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void receive_Click(object sender, System.EventArgs e)
		{
			int mailnumber;
			//連接服務器
			TcpClient tcpClient=new TcpClient();
			try
			{
				//連接POP3服務器
				tcpClient.Connect(servername.Text,Int32.Parse (mailport.Text));
			}
			catch
			{
				//顯示錯誤信息
				MessageBox.Show ("無法連接到POP3服務器"+servername.Text+"的"+mailport.Text+"端口!");
			}
			//從POP3郵件服務器取得回復
			NetworkStream netStream=tcpClient.GetStream ();
			if (netStream==null)
			{
				throw new Exception ("無法取得回復");
			}
			string returnMsg=ReadFromNetStream(ref netStream);
			checkForError(returnMsg);
			richTextBox1.AppendText("連接應答:"+returnMsg+"\r\n");

			//發送用戶名信息
			richTextBox1.AppendText("C:USER "+this.username.Text+"\r\n");
			WriteToNetStream(ref netStream,"USER "+this.username.Text);
			returnMsg=ReadFromNetStream(ref netStream);
			checkForError(returnMsg);
			richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
			//發送用戶密碼信息
			richTextBox1.AppendText("C:PASSWORD "+this.password.Text+"\r\n");
			WriteToNetStream(ref netStream,"PASS "+this.password .Text);
			returnMsg=ReadFromNetStream(ref netStream);
			checkForError(returnMsg);
			richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
			//檢查郵件
			mailnumber=EmailCheck(ref netStream);
			richTextBox1.AppendText("郵件數:"+mailnumber+" \r\n");
			//接收郵件
			for (int i=1;i<=mailnumber;i++)
			{
				richTextBox1.AppendText("C:RETR "+i.ToString() +" \r\n");
				WriteToNetStream(ref netStream,"RETR "+i.ToString());
				returnMsg=ReadFromNetStream(ref netStream);
				checkForError(returnMsg);
				richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
				ReadMail(ref netStream,i);

			}
			//斷開與POP3服務器的連接
			richTextBox1.AppendText("C:QUIT \r\n");
			WriteToNetStream(ref netStream,"QUIT ");
			returnMsg=ReadFromNetStream(ref netStream);
			checkForError(returnMsg);
			richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
		}

				
		//郵件檢查
		private int EmailCheck(ref NetworkStream NetStream)
		{
			richTextBox1.AppendText("C:STAT \r\n");
			WriteToNetStream(ref NetStream,"STAT");
			string returnMsg=ReadFromNetStream(ref NetStream);
			checkForError(returnMsg);
			richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
			string[] TotalStat=returnMsg.Split (new char[] {' '});
			int mailNumber=Int32.Parse (TotalStat[1]);
			return mailNumber;
		}

		//向POP3服務器寫入命令
		private void WriteToNetStream(ref NetworkStream NetStream,string Command)
		{
			string stringToSend=Command+"\r\n";
			Byte[] arrayToSend=Encoding.ASCII.GetBytes(stringToSend.ToCharArray());
			NetStream.Write(arrayToSend,0,arrayToSend.Length );
		}
		
		//從POP3讀取數據
		private string ReadFromNetStream(ref NetworkStream NetStream)
		{
			StringBuilder strReceived=new StringBuilder();
			StreamReader sr=new StreamReader (NetStream);
			String strLine=sr.ReadLine ();
			while(strLine==null || strLine.Length ==0)
			{
				strLine=sr.ReadLine ();
			}
			strReceived.Append(strLine);
			if (sr.Peek ()!=-1)
			{
				while((strLine=sr.ReadLine ())!=null)
				{
					strReceived.Append(strLine);
				}
			}
			return strReceived.ToString();
		}

		//檢查流中是否含有錯誤
		private void checkForError(String strMessage)
		{
			if (strMessage.IndexOf ("+OK")==-1)
				throw new Exception ("收到來自POP3服務器的錯誤信息:"+strMessage);
		}

       //讀郵件
		private void ReadMail(ref NetworkStream NetStream,int number)
		{
			int k=0;
			bool check=false;
			byte[] bb=new byte [6400];
			while(!check)
			{
				k=NetStream.Read (bb,0,bb.Length );
				string read=System.Text .Encoding .UTF8.GetString (bb,0,k);
				int x=read.IndexOf ("\r\n.\r\n");
				if (x!=-1)
				{
					check=true;
				}
				richTextBox2.AppendText (read);
				richTextBox1.AppendText("C:DELE "+number.ToString ()+"\r\n");
				WriteToNetStream(ref NetStream,"DELE "+number.ToString ());
				string returnMsg=ReadFromNetStream(ref NetStream);
				checkForError(returnMsg);
				richTextBox1.AppendText("POP3SERVER:"+returnMsg+"\r\n");
			}
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99精品国产麻豆不卡| 亚洲国产精品传媒在线观看| 国产欧美日韩不卡免费| 国产福利视频一区二区三区| 亚洲国产精品黑人久久久| 久久久亚洲国产美女国产盗摄| 国内久久精品视频| 最近日韩中文字幕| 欧美丰满少妇xxxbbb| 久久国产乱子精品免费女| 国产精品毛片大码女人 | 国产欧美日韩视频一区二区| 精品国产91亚洲一区二区三区婷婷| 成人性视频网站| 欧洲精品中文字幕| 国产成人精品综合在线观看 | 日本中文字幕一区二区视频| 精品日韩一区二区三区 | 一卡二卡欧美日韩| 亚洲综合精品久久| 午夜精品影院在线观看| 丝袜a∨在线一区二区三区不卡| 偷拍一区二区三区四区| 91黄色免费看| 欧美一区二区三区四区五区| 精品成人在线观看| 日韩国产欧美在线播放| 色哟哟一区二区在线观看| 欧美乱妇15p| 亚洲香蕉伊在人在线观| 激情成人午夜视频| 日韩欧美中文一区二区| 国产精品国产馆在线真实露脸| 亚洲免费观看高清完整| 麻豆精品在线视频| 91在线精品秘密一区二区| 欧美视频完全免费看| www欧美成人18+| 亚洲精品久久久蜜桃| 久久精品国产精品亚洲综合| 91精品国产入口| 精彩视频一区二区| www精品美女久久久tv| 国内精品伊人久久久久av一坑| 日韩免费观看高清完整版| 亚洲欧美一区二区不卡| 色综合色狠狠天天综合色| 亚洲精品视频在线| 欧美日韩国产首页| 国产精品色噜噜| 99国产精品视频免费观看| 亚洲人成在线观看一区二区| 欧洲国内综合视频| 日日骚欧美日韩| 久久婷婷国产综合精品青草| 成人一区二区在线观看| 一区二区三区在线免费| 欧美一级视频精品观看| 国产精品2024| 日韩欧美精品在线| 成人免费毛片嘿嘿连载视频| 亚洲欧美一区二区三区孕妇| 欧美乱妇15p| 国产成人免费在线观看| 亚洲另类一区二区| 日韩一区二区在线看片| 成人黄色免费短视频| 国产亚洲欧美一区在线观看| 精品系列免费在线观看| 成人免费一区二区三区在线观看| 国产精品自拍毛片| 艳妇臀荡乳欲伦亚洲一区| 欧美一级搡bbbb搡bbbb| 成人va在线观看| 日韩在线a电影| 国产欧美精品一区| 欧美日韩高清在线| 国产成人av影院| 亚洲成人自拍网| 欧美日韩国产首页在线观看| 国产麻豆视频一区| 亚洲国产精品v| 538prom精品视频线放| 五月天激情综合| 国产精品家庭影院| 日韩欧美色电影| 欧美四级电影在线观看| 福利电影一区二区三区| 国产精品国产自产拍在线| 日韩三级高清在线| 欧美性猛交xxxxxx富婆| 岛国av在线一区| 久久99精品视频| 亚洲国产一区二区a毛片| 中文字幕av资源一区| 欧美mv和日韩mv的网站| 欧美日韩视频在线观看一区二区三区| 亚洲第一福利视频在线| 国产色一区二区| 欧美va亚洲va香蕉在线| 精品视频色一区| 一本久道久久综合中文字幕| 国产精品1024| 激情都市一区二区| 麻豆精品在线观看| 久久精品国产秦先生| 天堂av在线一区| 一区二区欧美精品| 一区二区三区四区在线免费观看| 中文久久乱码一区二区| 久久久久88色偷偷免费| 欧美精品一区二区久久婷婷| 91精品午夜视频| 欧美日韩国产综合一区二区| 色婷婷精品大视频在线蜜桃视频 | 99国产精品国产精品久久| 国产福利精品一区二区| 国产黄色精品视频| 国产乱淫av一区二区三区| 国产精品亚洲第一| 国产精品一卡二| 福利视频网站一区二区三区| 国产成人精品一区二区三区四区| 国产米奇在线777精品观看| 激情欧美一区二区三区在线观看| 精品在线观看免费| 国产精品888| 99久久久免费精品国产一区二区 | 亚洲欧美中日韩| 亚洲精品福利视频网站| 亚洲成av人**亚洲成av**| 午夜久久久久久| 狠狠色伊人亚洲综合成人| 国产精品1区2区3区在线观看| 成人精品视频一区| 色av综合在线| 在线不卡免费av| 精品1区2区在线观看| 国产精品麻豆视频| 亚洲高清不卡在线| 成人午夜在线播放| 在线观看不卡视频| 欧美电影免费观看高清完整版在| 亚洲精品一区二区三区福利| 中文字幕巨乱亚洲| 亚洲1区2区3区4区| 国产在线播放一区| 色呦呦一区二区三区| 7777精品伊人久久久大香线蕉经典版下载 | 午夜精品在线看| 国产精品亚洲第一| 欧美综合一区二区三区| 精品国产91九色蝌蚪| 中文字幕一区二区三区四区不卡| 日韩精品成人一区二区在线| 国产久卡久卡久卡久卡视频精品| 91网站在线观看视频| 国产精品99久久久久久宅男| 色域天天综合网| 精品美女被调教视频大全网站| 国产精品免费av| 美女一区二区视频| 色综合天天综合| 色综合激情五月| 精品久久久久久最新网址| 亚洲欧美日韩一区| 精品一区二区综合| 精品视频在线免费看| 国产精品私人影院| 蜜桃久久精品一区二区| 国产亚洲精久久久久久| 午夜国产精品影院在线观看| 国产成人免费视频网站高清观看视频| 欧美午夜影院一区| 国产精品久久久久久久第一福利 | 欧美久久高跟鞋激| 欧美国产1区2区| 麻豆国产91在线播放| 欧美日韩在线不卡| 亚洲乱码中文字幕| 从欧美一区二区三区| 精品久久久久av影院| 亚洲电影在线免费观看| 99精品视频中文字幕| 国产欧美精品一区| 国产一区福利在线| 日韩欧美国产一区二区三区 | 欧美日本在线播放| 亚洲欧美国产77777| 成人激情开心网| 久久精品一区八戒影视| 精品亚洲免费视频| 欧美videofree性高清杂交| 婷婷开心激情综合| 欧美久久久久久久久久| 亚洲成av人片观看| 精品视频在线视频| 日韩国产在线观看| 日韩欧美卡一卡二| 九九九精品视频|