?? mainfrm.cs
字號(hào):
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net.Sockets;//用于處理網(wǎng)絡(luò)連接
using System.IO;
namespace QSendMail
{
/// <summary>
/// Form1 的摘要說(shuō)明。
/// </summary>
public class QSendMail : System.Windows.Forms.Form
{
internal System.Windows.Forms.Label label1;
internal System.Windows.Forms.TextBox txtSmtpIP;
internal System.Windows.Forms.GroupBox GroupBox1;
internal System.Windows.Forms.Button btnSend;
internal System.Windows.Forms.Label Label4;
internal System.Windows.Forms.GroupBox GroupBox2;
internal System.Windows.Forms.ListBox lstLog;
internal System.Windows.Forms.TextBox txtMsg;
internal System.Windows.Forms.TextBox txtFrom;
internal System.Windows.Forms.TextBox txtTo;
internal System.Windows.Forms.TextBox txtSub;
internal System.Windows.Forms.Label Label7;
internal System.Windows.Forms.Label Label8;
internal System.Windows.Forms.Label Label9;
internal System.Windows.Forms.Label Label10;
internal System.Windows.Forms.TextBox TextBox1;
internal System.Windows.Forms.TextBox TextBox2;
internal System.Windows.Forms.Label Label5;
internal System.Windows.Forms.TextBox TextBox3;
internal System.Windows.Forms.Label Label6;
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public QSendMail()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <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>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txtSmtpIP = new System.Windows.Forms.TextBox();
this.GroupBox1 = new System.Windows.Forms.GroupBox();
this.btnSend = new System.Windows.Forms.Button();
this.Label4 = new System.Windows.Forms.Label();
this.GroupBox2 = new System.Windows.Forms.GroupBox();
this.lstLog = new System.Windows.Forms.ListBox();
this.txtMsg = new System.Windows.Forms.TextBox();
this.txtFrom = new System.Windows.Forms.TextBox();
this.txtTo = new System.Windows.Forms.TextBox();
this.txtSub = new System.Windows.Forms.TextBox();
this.Label7 = new System.Windows.Forms.Label();
this.Label8 = new System.Windows.Forms.Label();
this.Label9 = new System.Windows.Forms.Label();
this.Label10 = new System.Windows.Forms.Label();
this.TextBox1 = new System.Windows.Forms.TextBox();
this.TextBox2 = new System.Windows.Forms.TextBox();
this.Label5 = new System.Windows.Forms.Label();
this.TextBox3 = new System.Windows.Forms.TextBox();
this.Label6 = new System.Windows.Forms.Label();
this.GroupBox1.SuspendLayout();
this.GroupBox2.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 23);
this.label1.TabIndex = 24;
this.label1.Text = "POP3服務(wù)器地址:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtSmtpIP
//
this.txtSmtpIP.Location = new System.Drawing.Point(128, 21);
this.txtSmtpIP.Name = "txtSmtpIP";
this.txtSmtpIP.Size = new System.Drawing.Size(160, 21);
this.txtSmtpIP.TabIndex = 21;
this.txtSmtpIP.Text = "";
//
// GroupBox1
//
this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnSend});
this.GroupBox1.Location = new System.Drawing.Point(0, 1);
this.GroupBox1.Name = "GroupBox1";
this.GroupBox1.Size = new System.Drawing.Size(448, 55);
this.GroupBox1.TabIndex = 28;
this.GroupBox1.TabStop = false;
this.GroupBox1.Text = "SMTP服務(wù)器設(shè)置";
this.GroupBox1.Enter += new System.EventHandler(this.GroupBox1_Enter);
//
// btnSend
//
this.btnSend.Location = new System.Drawing.Point(336, 16);
this.btnSend.Name = "btnSend";
this.btnSend.TabIndex = 14;
this.btnSend.Text = "發(fā)送";
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
//
// Label4
//
this.Label4.Location = new System.Drawing.Point(8, 88);
this.Label4.Name = "Label4";
this.Label4.Size = new System.Drawing.Size(56, 23);
this.Label4.TabIndex = 25;
this.Label4.Text = "發(fā)件人:";
this.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// GroupBox2
//
this.GroupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lstLog,
this.txtMsg,
this.txtFrom,
this.txtTo,
this.txtSub,
this.Label7,
this.Label8,
this.Label9,
this.Label10});
this.GroupBox2.Location = new System.Drawing.Point(0, 64);
this.GroupBox2.Name = "GroupBox2";
this.GroupBox2.Size = new System.Drawing.Size(448, 264);
this.GroupBox2.TabIndex = 29;
this.GroupBox2.TabStop = false;
this.GroupBox2.Text = "發(fā)送郵件";
//
// lstLog
//
this.lstLog.ItemHeight = 12;
this.lstLog.Location = new System.Drawing.Point(248, 40);
this.lstLog.Name = "lstLog";
this.lstLog.Size = new System.Drawing.Size(192, 76);
this.lstLog.TabIndex = 13;
//
// txtMsg
//
this.txtMsg.Location = new System.Drawing.Point(9, 121);
this.txtMsg.Multiline = true;
this.txtMsg.Name = "txtMsg";
this.txtMsg.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtMsg.Size = new System.Drawing.Size(432, 136);
this.txtMsg.TabIndex = 12;
this.txtMsg.Text = "test!";
this.txtMsg.TextChanged += new System.EventHandler(this.txtMsg_TextChanged);
//
// txtFrom
//
this.txtFrom.Location = new System.Drawing.Point(64, 24);
this.txtFrom.Name = "txtFrom";
this.txtFrom.Size = new System.Drawing.Size(160, 21);
this.txtFrom.TabIndex = 8;
this.txtFrom.Text = "";
//
// txtTo
//
this.txtTo.Location = new System.Drawing.Point(64, 49);
this.txtTo.Name = "txtTo";
this.txtTo.Size = new System.Drawing.Size(160, 21);
this.txtTo.TabIndex = 8;
this.txtTo.Text = "";
//
// txtSub
//
this.txtSub.Location = new System.Drawing.Point(64, 74);
this.txtSub.Name = "txtSub";
this.txtSub.Size = new System.Drawing.Size(160, 21);
this.txtSub.TabIndex = 8;
this.txtSub.Text = "";
//
// Label7
//
this.Label7.Location = new System.Drawing.Point(8, 49);
this.Label7.Name = "Label7";
this.Label7.Size = new System.Drawing.Size(56, 23);
this.Label7.TabIndex = 11;
this.Label7.Text = "收件人:";
this.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Label8
//
this.Label8.Location = new System.Drawing.Point(8, 72);
this.Label8.Name = "Label8";
this.Label8.Size = new System.Drawing.Size(56, 23);
this.Label8.TabIndex = 11;
this.Label8.Text = "主題:";
this.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Label9
//
this.Label9.Location = new System.Drawing.Point(8, 96);
this.Label9.Name = "Label9";
this.Label9.Size = new System.Drawing.Size(56, 23);
this.Label9.TabIndex = 11;
this.Label9.Text = "內(nèi)容:";
this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// Label10
//
this.Label10.Location = new System.Drawing.Point(244, 20);
this.Label10.Name = "Label10";
this.Label10.Size = new System.Drawing.Size(80, 23);
this.Label10.TabIndex = 11;
this.Label10.Text = "發(fā)送記錄:";
this.Label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// TextBox1
//
this.TextBox1.Location = new System.Drawing.Point(136, 144);
this.TextBox1.Name = "TextBox1";
this.TextBox1.PasswordChar = '*';
this.TextBox1.Size = new System.Drawing.Size(160, 21);
this.TextBox1.TabIndex = 16;
this.TextBox1.Text = "980409";
//
// TextBox2
//
this.TextBox2.Location = new System.Drawing.Point(136, 80);
this.TextBox2.Name = "TextBox2";
this.TextBox2.Size = new System.Drawing.Size(160, 21);
this.TextBox2.TabIndex = 20;
this.TextBox2.Text = "pop3.sina.com.cn";
//
// Label5
//
this.Label5.Location = new System.Drawing.Point(8, 112);
this.Label5.Name = "Label5";
this.Label5.Size = new System.Drawing.Size(112, 23);
this.Label5.TabIndex = 26;
this.Label5.Text = "用戶(hù)名:";
this.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// TextBox3
//
this.TextBox3.Location = new System.Drawing.Point(136, 112);
this.TextBox3.Name = "TextBox3";
this.TextBox3.Size = new System.Drawing.Size(160, 21);
this.TextBox3.TabIndex = 19;
this.TextBox3.Text = "qiugf_cn@sina.com";
//
// Label6
//
this.Label6.Location = new System.Drawing.Point(8, 144);
this.Label6.Name = "Label6";
this.Label6.Size = new System.Drawing.Size(112, 23);
this.Label6.TabIndex = 23;
this.Label6.Text = "密碼:";
this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// QSendMail
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(448, 333);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.txtSmtpIP,
this.GroupBox1,
this.Label4,
this.GroupBox2,
this.TextBox1,
this.TextBox2,
this.Label5,
this.TextBox3,
this.Label6});
this.Name = "QSendMail";
this.Text = "QSendMail";
this.GroupBox1.ResumeLayout(false);
this.GroupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應(yīng)用程序的主入口點(diǎn)。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new QSendMail());
}
private void txtMsg_TextChanged(object sender, System.EventArgs e)
{
}
private void btnSend_Click(object sender, System.EventArgs e)
{
lstLog.Items.Clear();
SendMail mail=new SendMail();
mail.MAILbody=this.txtMsg.Text;
mail.MAILfrom=this.txtFrom.Text;
mail.MAILserver=this.txtSmtpIP.Text;
mail.MAILsubject=this.txtSub.Text;
mail.MAILto=this.txtTo.Text;
Cursor cr = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
lstLog.Items.Add("開(kāi)始郵件發(fā)送");
if(mail.Send())
{
lstLog.Items.Add("郵件服務(wù)器發(fā)送成功");
}
else
{
lstLog.Items.Add("郵件服務(wù)器發(fā)送失敗");
}
Cursor.Current = cr;
}
private void GroupBox1_Enter(object sender, System.EventArgs e)
{
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -