SystemManage.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:27k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Drawing .Printing ;
- using System.Reflection ;
- using System.Runtime .InteropServices ;
- using System.Diagnostics ;
- using System.IO ;
- using MailManageSystem.RegisterAccount ;
- using MailSend;
- namespace MailManageSystem
- {
- /// <summary>
- /// Form1 的摘要说明。
- /// </summary>
- public class SystemManage : System.Windows.Forms.Form
- {
- private System.Windows.Forms.MainMenu mainMenu1;
- private System.Windows.Forms.MenuItem menuItem1;
- private System.Windows.Forms.MenuItem menuItem2;
- private System.Windows.Forms.MenuItem menuItem3;
- private System.Windows.Forms.MenuItem menuItem4;
- private System.Windows.Forms.MenuItem menuItem5;
- public System.Windows.Forms.TreeView treeView1;
- private System.Windows.Forms.Splitter splitter1;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Splitter splitter2;
- private System.Windows.Forms.RichTextBox richTextBox1;
- private System.Windows.Forms.ContextMenu contextMenu1;
- private System.Windows.Forms.MenuItem menuItem6;
- private System.Windows.Forms.ImageList imageList1;
- private System.Windows.Forms.MenuItem menuItem7;
- private System.Windows.Forms.MenuItem menuItem8;
- private System.Windows.Forms.MenuItem menuItem9;
- private System.Windows.Forms.MenuItem menuItem10;
- private System.Windows.Forms.MenuItem menuItem11;
- private System.Windows.Forms.MenuItem menuItem12;
- private System.Windows.Forms.MenuItem menuItem13;
- private System.Windows.Forms.MenuItem menuItem14;
- private System.Windows.Forms.MenuItem menuItem15;
- private System.Windows.Forms.MenuItem menuItem16;
- private System.Windows.Forms.MenuItem menuItem17;
- private System.Windows.Forms.MenuItem menuItem18;
- private System.Windows.Forms.MenuItem menuItem19;
- private System.ComponentModel.IContainer components;
- private System.Windows.Forms.Timer timer1;
- //用于调用发送邮件类的用户名
- public static string UserName;
- //用于调用发送邮件类的密码
- public static string PassWd;
- //用于调用发送邮件类发送邮件人地址
- public static string MailAddress;
- //新建的帐户名
- public static string AccountName;
- //用于调用发送邮件类的SMTP服务器名
- public static string SmtpName;
- public static int SmtpPort=21;
- public static int letterNumber;
- //确定是否启动计时器的标志位
- internal static bool flag=false;
- public string htmlbody;
- private System.Windows.Forms.ToolBarButton toolBarRecive;
- private System.Windows.Forms.ToolBarButton toolBarSend;
- private System.Windows.Forms.ToolBarButton toolBarWrite;
- private System.Windows.Forms.ToolBar toolBar1;
- private System.Windows.Forms.PrintDialog printDialog1;
- private System.Windows.Forms.ToolBarButton toolBarButton1;
- private System.Windows.Forms.StatusBar statusBar1;
- private System.Windows.Forms.StatusBarPanel sbWeclome;
- private System.Windows.Forms.StatusBarPanel sbTime;
- private System.Windows.Forms.StatusBarPanel sbCpmputerName;
- private System.Windows.Forms.StatusBarPanel sbIp;
- private System.Windows.Forms.MenuItem menuItem20;
- private System.Windows.Forms.MenuItem menuItem21;
- private System.Windows.Forms.MenuItem menuItem22;
- private System.Windows.Forms.MenuItem menuItem23;
- private System.Windows.Forms.MenuItem menuItem24;
- private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
- private System.Drawing.Printing.PrintDocument printDocument1;
- private System.Windows.Forms.MenuItem menuItem25;//语言编码
- //MailSend命名空间下的附加类
- AddExtra extra;
- private System.Windows.Forms.MenuItem menuItem26;
- private System.Windows.Forms.MenuItem menuItem27;
- private System.Windows.Forms.ImageList imageAccount;
- private System.Windows.Forms.ListView ltReceive;
- //API函数的声明
- [DllImport ("Shell32.dll")]
- public static extern int ShellAbout(IntPtr hWnd ,string szApp,string szOtherStuff,IntPtr hIcon);
- public SystemManage()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- Application.EnableVisualStyles ();
- Application.DoEvents ();
- 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.components = new System.ComponentModel.Container();
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SystemManage));
- this.mainMenu1 = new System.Windows.Forms.MainMenu();
- this.menuItem1 = new System.Windows.Forms.MenuItem();
- this.menuItem7 = new System.Windows.Forms.MenuItem();
- this.menuItem8 = new System.Windows.Forms.MenuItem();
- this.menuItem9 = new System.Windows.Forms.MenuItem();
- this.menuItem10 = new System.Windows.Forms.MenuItem();
- this.menuItem11 = new System.Windows.Forms.MenuItem();
- this.menuItem12 = new System.Windows.Forms.MenuItem();
- this.menuItem13 = new System.Windows.Forms.MenuItem();
- this.menuItem14 = new System.Windows.Forms.MenuItem();
- this.menuItem15 = new System.Windows.Forms.MenuItem();
- this.menuItem2 = new System.Windows.Forms.MenuItem();
- this.menuItem20 = new System.Windows.Forms.MenuItem();
- this.menuItem21 = new System.Windows.Forms.MenuItem();
- this.menuItem22 = new System.Windows.Forms.MenuItem();
- this.menuItem23 = new System.Windows.Forms.MenuItem();
- this.menuItem24 = new System.Windows.Forms.MenuItem();
- this.menuItem25 = new System.Windows.Forms.MenuItem();
- this.menuItem3 = new System.Windows.Forms.MenuItem();
- this.menuItem4 = new System.Windows.Forms.MenuItem();
- this.menuItem5 = new System.Windows.Forms.MenuItem();
- this.menuItem26 = new System.Windows.Forms.MenuItem();
- this.menuItem27 = new System.Windows.Forms.MenuItem();
- this.menuItem16 = new System.Windows.Forms.MenuItem();
- this.menuItem17 = new System.Windows.Forms.MenuItem();
- this.menuItem18 = new System.Windows.Forms.MenuItem();
- this.menuItem19 = new System.Windows.Forms.MenuItem();
- this.treeView1 = new System.Windows.Forms.TreeView();
- this.splitter1 = new System.Windows.Forms.Splitter();
- this.panel1 = new System.Windows.Forms.Panel();
- this.statusBar1 = new System.Windows.Forms.StatusBar();
- this.sbWeclome = new System.Windows.Forms.StatusBarPanel();
- this.sbTime = new System.Windows.Forms.StatusBarPanel();
- this.sbCpmputerName = new System.Windows.Forms.StatusBarPanel();
- this.sbIp = new System.Windows.Forms.StatusBarPanel();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.splitter2 = new System.Windows.Forms.Splitter();
- this.ltReceive = new System.Windows.Forms.ListView();
- this.contextMenu1 = new System.Windows.Forms.ContextMenu();
- this.menuItem6 = new System.Windows.Forms.MenuItem();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.timer1 = new System.Windows.Forms.Timer(this.components);
- this.toolBarRecive = new System.Windows.Forms.ToolBarButton();
- this.toolBarSend = new System.Windows.Forms.ToolBarButton();
- this.toolBarWrite = new System.Windows.Forms.ToolBarButton();
- this.toolBar1 = new System.Windows.Forms.ToolBar();
- this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
- this.printDialog1 = new System.Windows.Forms.PrintDialog();
- this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
- this.printDocument1 = new System.Drawing.Printing.PrintDocument();
- this.imageAccount = new System.Windows.Forms.ImageList(this.components);
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.sbWeclome)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbTime)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbCpmputerName)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbIp)).BeginInit();
- this.SuspendLayout();
- //
- // mainMenu1
- //
- this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem1,
- this.menuItem2,
- this.menuItem3,
- this.menuItem16});
- //
- // menuItem1
- //
- this.menuItem1.Index = 0;
- this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem7,
- this.menuItem8,
- this.menuItem9,
- this.menuItem10,
- this.menuItem11,
- this.menuItem12,
- this.menuItem13,
- this.menuItem14,
- this.menuItem15});
- this.menuItem1.Text = "文件(F)";
- //
- // menuItem7
- //
- this.menuItem7.Index = 0;
- this.menuItem7.Text = "收取当前邮箱邮件";
- //
- // menuItem8
- //
- this.menuItem8.Index = 1;
- this.menuItem8.Text = "收取所有邮箱邮件";
- //
- // menuItem9
- //
- this.menuItem9.Index = 2;
- this.menuItem9.Text = "发送所有待发邮件";
- //
- // menuItem10
- //
- this.menuItem10.Index = 3;
- this.menuItem10.Text = "-";
- //
- // menuItem11
- //
- this.menuItem11.Index = 4;
- this.menuItem11.Text = "打印机设置";
- this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
- //
- // menuItem12
- //
- this.menuItem12.Index = 5;
- this.menuItem12.Text = "打印预览";
- this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
- //
- // menuItem13
- //
- this.menuItem13.Index = 6;
- this.menuItem13.Text = "打印";
- //
- // menuItem14
- //
- this.menuItem14.Index = 7;
- this.menuItem14.Text = "-";
- //
- // menuItem15
- //
- this.menuItem15.Index = 8;
- this.menuItem15.Text = "退出";
- this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
- //
- // menuItem2
- //
- this.menuItem2.Index = 1;
- this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem20});
- this.menuItem2.Text = "查看(V)";
- //
- // menuItem20
- //
- this.menuItem20.Index = 0;
- this.menuItem20.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem21,
- this.menuItem22,
- this.menuItem23,
- this.menuItem24,
- this.menuItem25});
- this.menuItem20.Text = "邮件文字大小";
- //
- // menuItem21
- //
- this.menuItem21.Index = 0;
- this.menuItem21.Text = "最大";
- //
- // menuItem22
- //
- this.menuItem22.Index = 1;
- this.menuItem22.Text = "较大";
- //
- // menuItem23
- //
- this.menuItem23.Index = 2;
- this.menuItem23.Text = "中等";
- //
- // menuItem24
- //
- this.menuItem24.Index = 3;
- this.menuItem24.Text = "较小";
- //
- // menuItem25
- //
- this.menuItem25.Index = 4;
- this.menuItem25.Text = "最小";
- //
- // menuItem3
- //
- this.menuItem3.Index = 2;
- this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem4,
- this.menuItem5,
- this.menuItem26,
- this.menuItem27});
- this.menuItem3.Text = "邮箱(B)";
- //
- // menuItem4
- //
- this.menuItem4.Index = 0;
- this.menuItem4.Text = "修改邮箱属性";
- //
- // menuItem5
- //
- this.menuItem5.Index = 1;
- this.menuItem5.Text = "新建邮箱帐户";
- this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
- //
- // menuItem26
- //
- this.menuItem26.Index = 2;
- this.menuItem26.Text = "-";
- //
- // menuItem27
- //
- this.menuItem27.Index = 3;
- this.menuItem27.Text = "删除邮箱";
- this.menuItem27.Click += new System.EventHandler(this.menuItem27_Click);
- //
- // menuItem16
- //
- this.menuItem16.Index = 3;
- this.menuItem16.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem17,
- this.menuItem18,
- this.menuItem19});
- this.menuItem16.Text = "帮助(H)";
- //
- // menuItem17
- //
- this.menuItem17.Index = 0;
- this.menuItem17.Text = "帮助主题";
- //
- // menuItem18
- //
- this.menuItem18.Index = 1;
- this.menuItem18.Text = "-";
- //
- // menuItem19
- //
- this.menuItem19.Index = 2;
- this.menuItem19.Text = "关于";
- this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
- //
- // treeView1
- //
- this.treeView1.Dock = System.Windows.Forms.DockStyle.Left;
- this.treeView1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.treeView1.ImageList = this.imageAccount;
- this.treeView1.Location = new System.Drawing.Point(0, 43);
- this.treeView1.Name = "treeView1";
- this.treeView1.Size = new System.Drawing.Size(121, 462);
- this.treeView1.TabIndex = 1;
- this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
- //
- // splitter1
- //
- this.splitter1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
- this.splitter1.Location = new System.Drawing.Point(121, 43);
- this.splitter1.Name = "splitter1";
- this.splitter1.Size = new System.Drawing.Size(5, 462);
- this.splitter1.TabIndex = 2;
- this.splitter1.TabStop = false;
- //
- // panel1
- //
- this.panel1.Controls.Add(this.statusBar1);
- this.panel1.Controls.Add(this.richTextBox1);
- this.panel1.Controls.Add(this.splitter2);
- this.panel1.Controls.Add(this.ltReceive);
- this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel1.Location = new System.Drawing.Point(126, 43);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(762, 462);
- this.panel1.TabIndex = 3;
- //
- // statusBar1
- //
- this.statusBar1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.statusBar1.Location = new System.Drawing.Point(0, 430);
- this.statusBar1.Name = "statusBar1";
- this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
- this.sbWeclome,
- this.sbTime,
- this.sbCpmputerName,
- this.sbIp});
- this.statusBar1.ShowPanels = true;
- this.statusBar1.Size = new System.Drawing.Size(762, 32);
- this.statusBar1.TabIndex = 3;
- //
- // sbWeclome
- //
- this.sbWeclome.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
- this.sbWeclome.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
- this.sbWeclome.Text = "欢迎使用ArgentSwan邮件管理系统";
- this.sbWeclome.Width = 186;
- //
- // sbTime
- //
- this.sbTime.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
- this.sbTime.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
- this.sbTime.Width = 186;
- //
- // sbCpmputerName
- //
- this.sbCpmputerName.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
- this.sbCpmputerName.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
- this.sbCpmputerName.Width = 186;
- //
- // sbIp
- //
- this.sbIp.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
- this.sbIp.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
- this.sbIp.Width = 186;
- //
- // richTextBox1
- //
- this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.richTextBox1.Location = new System.Drawing.Point(0, 141);
- this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(762, 321);
- this.richTextBox1.TabIndex = 2;
- this.richTextBox1.Text = "";
- //
- // splitter2
- //
- this.splitter2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
- this.splitter2.Dock = System.Windows.Forms.DockStyle.Top;
- this.splitter2.Location = new System.Drawing.Point(0, 136);
- this.splitter2.Name = "splitter2";
- this.splitter2.Size = new System.Drawing.Size(762, 5);
- this.splitter2.TabIndex = 1;
- this.splitter2.TabStop = false;
- //
- // ltReceive
- //
- this.ltReceive.Dock = System.Windows.Forms.DockStyle.Top;
- this.ltReceive.Location = new System.Drawing.Point(0, 0);
- this.ltReceive.MultiSelect = false;
- this.ltReceive.Name = "ltReceive";
- this.ltReceive.Size = new System.Drawing.Size(762, 136);
- this.ltReceive.TabIndex = 0;
- this.ltReceive.View = System.Windows.Forms.View.Details;
- //
- // contextMenu1
- //
- this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem6});
- //
- // menuItem6
- //
- this.menuItem6.Index = 0;
- this.menuItem6.Text = "默认连接";
- //
- // imageList1
- //
- this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
- this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // timer1
- //
- this.timer1.Enabled = true;
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
- //
- // toolBarRecive
- //
- this.toolBarRecive.DropDownMenu = this.contextMenu1;
- this.toolBarRecive.ImageIndex = 0;
- this.toolBarRecive.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
- this.toolBarRecive.Text = "收取";
- //
- // toolBarSend
- //
- this.toolBarSend.ImageIndex = 1;
- this.toolBarSend.Text = "发送";
- //
- // toolBarWrite
- //
- this.toolBarWrite.ImageIndex = 2;
- this.toolBarWrite.Text = "写邮件";
- //
- // toolBar1
- //
- this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
- this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
- this.toolBarRecive,
- this.toolBarSend,
- this.toolBarButton1,
- this.toolBarWrite});
- this.toolBar1.ButtonSize = new System.Drawing.Size(70, 37);
- this.toolBar1.Divider = false;
- this.toolBar1.DropDownArrows = true;
- this.toolBar1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.toolBar1.ImageList = this.imageList1;
- this.toolBar1.Location = new System.Drawing.Point(0, 0);
- this.toolBar1.Name = "toolBar1";
- this.toolBar1.ShowToolTips = true;
- this.toolBar1.Size = new System.Drawing.Size(888, 43);
- this.toolBar1.TabIndex = 0;
- this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
- //
- // toolBarButton1
- //
- this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
- //
- // printPreviewDialog1
- //
- this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
- this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
- this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
- this.printPreviewDialog1.Enabled = true;
- this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
- this.printPreviewDialog1.Location = new System.Drawing.Point(44, 58);
- this.printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
- this.printPreviewDialog1.Name = "printPreviewDialog1";
- this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
- this.printPreviewDialog1.Visible = false;
- //
- // imageAccount
- //
- this.imageAccount.ImageSize = new System.Drawing.Size(16, 16);
- this.imageAccount.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageAccount.ImageStream")));
- this.imageAccount.TransparentColor = System.Drawing.Color.Transparent;
- //
- // SystemManage
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(888, 505);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.splitter1);
- this.Controls.Add(this.treeView1);
- this.Controls.Add(this.toolBar1);
- this.Menu = this.mainMenu1;
- this.Name = "SystemManage";
- this.Text = "邮件管理系统";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.panel1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.sbWeclome)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbTime)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbCpmputerName)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.sbIp)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new SystemManage());
- }
- PrintDocument print=new PrintDocument ();
- private void menuItem11_Click(object sender, System.EventArgs e)
- {
- this.printDialog1 .Document =print;
- if(this.printDialog1 .ShowDialog ()==DialogResult.OK )
- {
- print.Print ();
- }
- }
- private void printDocument1_PrintPage(object sender,
- System.Drawing.Printing.PrintPageEventArgs e)
- {
- e.Graphics.DrawString(this.richTextBox1 .Text ,
- new Font("Arial", 80, FontStyle.Bold), Brushes.Black, 150, 125);
- }
- private void menuItem12_Click(object sender, System.EventArgs e)
- {
- try
- {
- this.printDocument1.PrintPage += new
- System.Drawing.Printing.PrintPageEventHandler
- (this.printDocument1_PrintPage);
- this.printPreviewDialog1 .Document =this.printDocument1 ;
- this.printPreviewDialog1 .ShowDialog ();
- }
- catch(Exception ex)
- {
- // MessageBox.Show ("请确定你已经安装了打印机");
- MessageBox.Show (ex.ToString ());
- }
- }
- //退出应用程序
- private void menuItem15_Click(object sender, System.EventArgs e)
- {
- Application.Exit ();
- }
- private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
- {
- switch(toolBar1.Buttons .IndexOf (e.Button ))
- {
- case 0:
- break;
- case 1:
- break;
- default:
- if(AccountName==null)
- {
- MessageBox.Show ("请先注册帐号!");
- return;
- }
- SendMailForm send=new SendMailForm ();
- send.Show ();
- break;
- }
- }
- private void menuItem5_Click(object sender, System.EventArgs e)
- {
- try
- {
- NewAccount newaccount=new NewAccount ();
- newaccount.Show ();
- }
- catch(Exception ee)
- {
- MessageBox.Show (ee.ToString ());
- }
- }
- private void Form1_Load(object sender, System.EventArgs e)
- {
- extra=new AddExtra();
- this.sbCpmputerName.Text ="主机名:"+extra.GetName ();
- this.sbTime .Text =extra.GetTime ();
- this.sbIp .Text ="IP地址:";
- string []IpAddress=extra.GetIP ();
- for(int i=0;i<IpAddress.Length/2;i++)
- {
- this.sbIp .Text+=IpAddress[i];
- }
- LoadAccount();
- }
- //再加载窗口的同时加载已经注册的帐户
- public void LoadAccount()
- {
- try
- {
- AccountOperate acOperate=new AccountOperate();
- ArrayList Array=acOperate.ReadFromDataBase ("select AccountName from Users","AccountName");
- for( int i=0;i<Array.Count ;i++)
- {
- TreeNode Nodes=new TreeNode (Array[i].ToString (),0,0);
- treeView1 .Nodes .Add (Nodes);
- TreeNode SubNode1=new TreeNode ("收信箱",1,1);
- Nodes.Nodes .Add (SubNode1);
- TreeNode SubNode2=new TreeNode ("发件箱",2,2);
- Nodes.Nodes .Add (SubNode2);
- TreeNode SubNode3=new TreeNode ("已发送邮件箱",3,3);
- Nodes.Nodes .Add (SubNode3);
- TreeNode SubNode4=new TreeNode ("垃圾邮件箱",4,4);
- Nodes.Nodes .Add (SubNode4);
- TreeNode SubNode5=new TreeNode ("废件箱",5,5);
- Nodes.Nodes .Add (SubNode5);
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show (ex.ToString ());
- }
- this.ltReceive.Columns .Add("作者",100,HorizontalAlignment.Center);
- this.ltReceive.Columns .Add ("主题",150,HorizontalAlignment.Center);
- this.ltReceive.Columns .Add ("日期",200,HorizontalAlignment.Center);
- this.ltReceive.Columns .Add ("大小",120,HorizontalAlignment.Center);
- }
- //在新建一个帐户的同时,将它加载到TreeView控件中
- public void addNewAccount()
- {
- try
- {
- TreeNode Nodes=new TreeNode (AccountName);
- treeView1 .Nodes .Add (Nodes);
- TreeNode SubNode1=new TreeNode ("收信箱",1,1);
- Nodes.Nodes .Add (SubNode1);
- TreeNode SubNode2=new TreeNode ("发件箱",2,2);
- Nodes.Nodes .Add (SubNode2);
- TreeNode SubNode3=new TreeNode ("已发送邮件箱",3,3);
- Nodes.Nodes .Add (SubNode3);
- TreeNode SubNode4=new TreeNode ("垃圾邮件箱",4,4);
- Nodes.Nodes .Add (SubNode4);
- TreeNode SubNode5=new TreeNode ("废件箱",5,5);
- Nodes.Nodes .Add (SubNode5);
- }
- catch(Exception ex)
- {
- MessageBox.Show (ex.ToString ());
- }
- }
- private void menuItem19_Click(object sender, System.EventArgs e)
- {
- //调用关于窗口
- Assembly ass=Assembly.GetExecutingAssembly();
- FileVersionInfo myVersion=FileVersionInfo.GetVersionInfo(ass.Location );
- ShellAbout(this.Handle ,"邮件收发系统#","版本"+myVersion.FileMajorPart +"."+myVersion.FileMinorPart+"." +myVersion.CompanyName ,this.Icon .Handle );
- }
- private void timer1_Tick(object sender, System.EventArgs e)
- {
- //新建帐号的时候
- if(flag)
- {
- addNewAccount();
- }
- flag=false;
- }
- //在选中一个帐户的时候,所有的相关信息跟着改变(主要是发送邮件的参数)
- private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
- {
- //帐户操作的有关类
- AccountOperate acOperate=new AccountOperate();
- try
- {
- //判断是否是根节点
- if(e.Node .Parent==null)
- {
- AccountName =e.Node.Text ;
- }
- else if(e.Node .Parent !=null)
- {
- AccountName=e.Node .Parent .Text ;
- }
- string []accountInfo=acOperate.AccountFileInfo("Select userName,PassW, MailAddress,Smtp,Port from users where AccountName='"+AccountName +"'");
- UserName=accountInfo[0];
- PassWd=accountInfo[1];
- MailAddress=accountInfo[2];
- SmtpName=accountInfo[3];
- SmtpPort=int.Parse (accountInfo[4]);
- }
- catch(Exception ex)
- {
- MessageBox.Show (ex.ToString ());
- }
- }
- //删除选定帐户的操作
- private void menuItem27_Click(object sender, System.EventArgs e)
- {
- try
- {
- AccountOperate acOperate=new AccountOperate();
- acOperate.AddDelAccount("delete * from users where AccountName='"+AccountName+"'");
- if(this.treeView1.SelectedNode !=null)
- {
- if(MessageBox.Show ("你确定要删除吗?","请确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
- {
- this.treeView1.Nodes .Remove(this.treeView1 .SelectedNode );
- }
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- }
- }