⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmconfpop3.cs

📁 C#写的Email邮件客户端程序skyemail.
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
//using System.Net;
//using System.Net.Sockets; 
using System.IO; 
using System.Text;  
using System.Security.Cryptography;

namespace SkyMail
{
	/// <summary>
	/// FrmConfPop3 的摘要说明。
	/// </summary>
	public class FrmConfPop3 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox Txtusername;
		private System.Windows.Forms.TextBox Txtpop3name;
		private System.Windows.Forms.TextBox Txtuserpwd;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.CheckBox Chkbak;
		private System.Windows.Forms.TextBox Txtpop3port;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label4;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FrmConfPop3()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

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

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.Txtusername = new System.Windows.Forms.TextBox();
			this.Txtpop3name = new System.Windows.Forms.TextBox();
			this.Txtuserpwd = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.Chkbak = new System.Windows.Forms.CheckBox();
			this.Txtpop3port = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.label6 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// Txtusername
			// 
			this.Txtusername.Location = new System.Drawing.Point(88, 48);
			this.Txtusername.Name = "Txtusername";
			this.Txtusername.Size = new System.Drawing.Size(88, 21);
			this.Txtusername.TabIndex = 42;
			this.Txtusername.Text = "";
			// 
			// Txtpop3name
			// 
			this.Txtpop3name.Location = new System.Drawing.Point(88, 20);
			this.Txtpop3name.Name = "Txtpop3name";
			this.Txtpop3name.Size = new System.Drawing.Size(128, 21);
			this.Txtpop3name.TabIndex = 40;
			this.Txtpop3name.Text = "";
			// 
			// Txtuserpwd
			// 
			this.Txtuserpwd.Location = new System.Drawing.Point(216, 48);
			this.Txtuserpwd.Name = "Txtuserpwd";
			this.Txtuserpwd.PasswordChar = '*';
			this.Txtuserpwd.Size = new System.Drawing.Size(88, 21);
			this.Txtuserpwd.TabIndex = 43;
			this.Txtuserpwd.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(16, 56);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(56, 16);
			this.label3.TabIndex = 39;
			this.label3.Text = "账 户 名";
			// 
			// Chkbak
			// 
			this.Chkbak.Location = new System.Drawing.Point(16, 80);
			this.Chkbak.Name = "Chkbak";
			this.Chkbak.Size = new System.Drawing.Size(176, 24);
			this.Chkbak.TabIndex = 44;
			this.Chkbak.Text = "在此服务器上保留邮件备份";
			// 
			// Txtpop3port
			// 
			this.Txtpop3port.Location = new System.Drawing.Point(272, 20);
			this.Txtpop3port.Name = "Txtpop3port";
			this.Txtpop3port.Size = new System.Drawing.Size(32, 21);
			this.Txtpop3port.TabIndex = 41;
			this.Txtpop3port.Text = "110";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 15);
			this.label1.TabIndex = 38;
			this.label1.Text = "POP3服务器";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(120, 112);
			this.button1.Name = "button1";
			this.button1.TabIndex = 45;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(232, 112);
			this.button2.Name = "button2";
			this.button2.TabIndex = 46;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(240, 24);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(32, 23);
			this.label6.TabIndex = 48;
			this.label6.Text = "端口";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(184, 56);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 12);
			this.label4.TabIndex = 49;
			this.label4.Text = "密码";
			// 
			// FrmConfPop3
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(320, 149);
			this.ControlBox = false;
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.label4,
																		  this.label6,
																		  this.button2,
																		  this.button1,
																		  this.Txtusername,
																		  this.Txtpop3name,
																		  this.Txtuserpwd,
																		  this.label3,
																		  this.Chkbak,
																		  this.Txtpop3port,
																		  this.label1});
			this.MinimizeBox = false;
			this.Name = "FrmConfPop3";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.ResumeLayout(false);

		}
		#endregion

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			bool  bnull =false;
			if(Txtpop3name.Text.Trim().Length<1)
			{bnull=true;}
			if(Txtpop3port.Text.Trim().Length<1)
			{bnull=true;}
			if(Txtusername.Text.Trim().Length<1)
			{bnull=true;}
			if(Txtuserpwd.Text.Trim().Length<1)
			{bnull=true;}
			string Acon="";
			string password="wanwenguo";
			if (password.Length > 8)
				password=password.Substring(0, 8);
			else if (password.Length < 8)
			{
				int add=8-password.Length;
				for (int i=0; i<add; i++)
					password=password+i;
			}
			FileInfo d=new FileInfo("skymail1.wg");
			if(d.Exists)
			{
				FileStream fin = new FileStream("skymail1.wg", FileMode.Open, FileAccess.Read);
				UnicodeEncoding UE = new UnicodeEncoding();
				DESCryptoServiceProvider des = new DESCryptoServiceProvider();
				SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
				byte[] key = UE.GetBytes(password);
				CryptoStream cryptostreamDecr = new CryptoStream(fin,rijn.CreateDecryptor(key,key),CryptoStreamMode.Read);
				Acon=(new StreamReader(cryptostreamDecr, new UnicodeEncoding())).ReadToEnd();
				cryptostreamDecr.Close(); 
				fin.Close();
			} 
			if(!bnull)
			{
				Acon=Acon+"pop3name:"+ Txtpop3name.Text +"/";
				Acon=Acon+"pop3port:"+ Txtpop3port.Text +"/";
				Acon=Acon+"username:"+ Txtusername.Text +"/";
				Acon=Acon+"userpwd:"+ Txtuserpwd.Text +"/";
				Acon=Acon+"emailbak:"+ Chkbak.Checked.ToString()  +"\r\n";
				//写入其他的POP3帐号信息
				FileStream fout = new FileStream("skymail1.wg", FileMode.OpenOrCreate, FileAccess.ReadWrite);
				Byte[] bytearrayinput=ConvertStringToByteArray(Acon);
				
				UnicodeEncoding UE = new UnicodeEncoding();
				byte[] key = UE.GetBytes(password);
				DESCryptoServiceProvider des = new DESCryptoServiceProvider();
				SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
				CryptoStream encStream = new CryptoStream(fout,rijn.CreateEncryptor(key,key),CryptoStreamMode.Write);
				encStream.Write(bytearrayinput,0,bytearrayinput.Length);
				encStream.Close();  
				fout.Close();
				this.Close();
				this.Dispose(); 

			}
		}

			public static Byte[] ConvertStringToByteArray(String s)
			{
				return (new UnicodeEncoding()).GetBytes(s);
			}

			}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -