2008-03-11 Ivan N. Zlatev <contact@i-nz.net>
[mono.git] / mcs / class / Managed.Windows.Forms / samples / mailclient.cs
1 using System;
2 using System.Drawing;
3 using System.Collections;
4 using System.ComponentModel;
5 using System.Windows.Forms;
6 using System.Data;
7
8 namespace smtp_csharp
9 {
10   public class frmMain : System.Windows.Forms.Form
11   {
12     internal System.Windows.Forms.GroupBox GroupBox2;
13     internal System.Windows.Forms.Label LabelAuthType;
14     internal System.Windows.Forms.ComboBox cmbAuth;
15     internal System.Windows.Forms.Label LabelPopServer;
16     internal System.Windows.Forms.TextBox txtPOPServer;
17     internal System.Windows.Forms.Label LabelPasswd;
18     internal System.Windows.Forms.TextBox txtPassword;
19     internal System.Windows.Forms.Label LabelUsername;
20     internal System.Windows.Forms.TextBox txtUsername;
21     internal System.Windows.Forms.Label LabelServer;
22     internal System.Windows.Forms.TextBox txtServer;
23     internal System.Windows.Forms.GroupBox GroupBox1;
24     internal System.Windows.Forms.Button cmdSend;
25     internal System.Windows.Forms.Label LabelMessage;
26     internal System.Windows.Forms.Label LabelSubject;
27     internal System.Windows.Forms.Label LabelSentTo;
28     internal System.Windows.Forms.Label LabelMailFrom;
29     internal System.Windows.Forms.TextBox txtMessageText;
30     internal System.Windows.Forms.TextBox txtMessageSubject;
31     internal System.Windows.Forms.TextBox txtSendTo;
32     internal System.Windows.Forms.TextBox txtMailFrom;
33
34     private System.ComponentModel.Container components = null;
35
36     public frmMain()
37     {
38       InitializeComponent();
39     }
40
41     protected override void Dispose( bool disposing )
42     {
43       if( disposing )
44       {
45         if (components != null) 
46         {
47           components.Dispose();
48         }
49       }
50       base.Dispose( disposing );
51     }
52
53     private void InitializeComponent()
54     {
55       this.GroupBox2 = new System.Windows.Forms.GroupBox();
56       this.LabelAuthType = new System.Windows.Forms.Label();
57       this.cmbAuth = new System.Windows.Forms.ComboBox();
58       this.LabelPopServer = new System.Windows.Forms.Label();
59       this.txtPOPServer = new System.Windows.Forms.TextBox();
60       this.LabelPasswd = new System.Windows.Forms.Label();
61       this.txtPassword = new System.Windows.Forms.TextBox();
62       this.LabelUsername = new System.Windows.Forms.Label();
63       this.txtUsername = new System.Windows.Forms.TextBox();
64       this.LabelServer = new System.Windows.Forms.Label();
65       this.txtServer = new System.Windows.Forms.TextBox();
66       this.GroupBox1 = new System.Windows.Forms.GroupBox();
67       this.cmdSend = new System.Windows.Forms.Button();
68       this.LabelMessage = new System.Windows.Forms.Label();
69       this.LabelSubject = new System.Windows.Forms.Label();
70       this.LabelSentTo = new System.Windows.Forms.Label();
71       this.LabelMailFrom = new System.Windows.Forms.Label();
72       this.txtMessageText = new System.Windows.Forms.TextBox();
73       this.txtMessageSubject = new System.Windows.Forms.TextBox();
74       this.txtSendTo = new System.Windows.Forms.TextBox();
75       this.txtMailFrom = new System.Windows.Forms.TextBox();
76       this.GroupBox2.SuspendLayout();
77       this.GroupBox1.SuspendLayout();
78       this.SuspendLayout();
79
80       this.GroupBox2.Controls.Add(this.LabelAuthType);
81       this.GroupBox2.Controls.Add(this.cmbAuth);
82       this.GroupBox2.Controls.Add(this.LabelPopServer);
83       this.GroupBox2.Controls.Add(this.txtPOPServer);
84       this.GroupBox2.Controls.Add(this.LabelPasswd);
85       this.GroupBox2.Controls.Add(this.txtPassword);
86       this.GroupBox2.Controls.Add(this.LabelUsername);
87       this.GroupBox2.Controls.Add(this.txtUsername);
88       this.GroupBox2.Controls.Add(this.LabelServer);
89       this.GroupBox2.Controls.Add(this.txtServer);
90       this.GroupBox2.Location = new System.Drawing.Point(264, 10);
91       this.GroupBox2.Name = "GroupBox2";
92       this.GroupBox2.Size = new System.Drawing.Size(240, 216);
93       this.GroupBox2.TabIndex = 11;
94       this.GroupBox2.TabStop = false;
95       this.GroupBox2.Text = "Connection Settings";
96
97       this.LabelAuthType.AutoSize = true;
98       this.LabelAuthType.Location = new System.Drawing.Point(24, 98);
99       this.LabelAuthType.Name = "LabelAuthType";
100       this.LabelAuthType.Size = new System.Drawing.Size(101, 16);
101       this.LabelAuthType.TabIndex = 14;
102       this.LabelAuthType.Text = "Authentication type";
103       this.LabelAuthType.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
104
105       this.cmbAuth.Location = new System.Drawing.Point(128, 96);
106       this.cmbAuth.Name = "cmbAuth";
107       this.cmbAuth.Size = new System.Drawing.Size(96, 21);
108       this.cmbAuth.TabIndex = 13;
109       this.cmbAuth.Text = "ComboBox1";
110
111       this.LabelPopServer.AutoSize = true;
112       this.LabelPopServer.Location = new System.Drawing.Point(24, 122);
113       this.LabelPopServer.Name = "LabelPopServer";
114       this.LabelPopServer.Size = new System.Drawing.Size(71, 16);
115       this.LabelPopServer.TabIndex = 12;
116       this.LabelPopServer.Text = "POP3 Server";
117       this.LabelPopServer.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
118
119       this.txtPOPServer.Location = new System.Drawing.Point(104, 120);
120       this.txtPOPServer.Name = "txtPOPServer";
121       this.txtPOPServer.Size = new System.Drawing.Size(120, 20);
122       this.txtPOPServer.TabIndex = 11;
123       this.txtPOPServer.Text = "";
124
125       this.LabelPasswd.AutoSize = true;
126       this.LabelPasswd.Location = new System.Drawing.Point(24, 74);
127       this.LabelPasswd.Name = "LabelPasswd";
128       this.LabelPasswd.Size = new System.Drawing.Size(54, 16);
129       this.LabelPasswd.TabIndex = 10;
130       this.LabelPasswd.Text = "Password";
131       this.LabelPasswd.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
132
133       this.txtPassword.Location = new System.Drawing.Point(88, 72);
134       this.txtPassword.Name = "txtPassword";
135       this.txtPassword.Size = new System.Drawing.Size(136, 20);
136       this.txtPassword.TabIndex = 9;
137       this.txtPassword.Text = "";
138
139       this.LabelUsername.AutoSize = true;
140       this.LabelUsername.Location = new System.Drawing.Point(24, 50);
141       this.LabelUsername.Name = "LabelUsername";
142       this.LabelUsername.Size = new System.Drawing.Size(56, 16);
143       this.LabelUsername.TabIndex = 8;
144       this.LabelUsername.Text = "Username";
145       this.LabelUsername.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
146
147       this.txtUsername.Location = new System.Drawing.Point(88, 48);
148       this.txtUsername.Name = "txtUsername";
149       this.txtUsername.Size = new System.Drawing.Size(136, 20);
150       this.txtUsername.TabIndex = 7;
151       this.txtUsername.Text = "";
152
153       this.LabelServer.AutoSize = true;
154       this.LabelServer.Location = new System.Drawing.Point(24, 26);
155       this.LabelServer.Name = "LabelServer";
156       this.LabelServer.Size = new System.Drawing.Size(38, 16);
157       this.LabelServer.TabIndex = 6;
158       this.LabelServer.Text = "Server";
159       this.LabelServer.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
160
161       this.txtServer.Location = new System.Drawing.Point(88, 24);
162       this.txtServer.Name = "txtServer";
163       this.txtServer.Size = new System.Drawing.Size(136, 20);
164       this.txtServer.TabIndex = 5;
165       this.txtServer.Text = "localhost";
166
167       this.GroupBox1.Controls.Add(this.cmdSend);
168       this.GroupBox1.Controls.Add(this.LabelMessage);
169       this.GroupBox1.Controls.Add(this.LabelSubject);
170       this.GroupBox1.Controls.Add(this.LabelSentTo);
171       this.GroupBox1.Controls.Add(this.LabelMailFrom);
172       this.GroupBox1.Controls.Add(this.txtMessageText);
173       this.GroupBox1.Controls.Add(this.txtMessageSubject);
174       this.GroupBox1.Controls.Add(this.txtSendTo);
175       this.GroupBox1.Controls.Add(this.txtMailFrom);
176       this.GroupBox1.Location = new System.Drawing.Point(8, 10);
177       this.GroupBox1.Name = "GroupBox1";
178       this.GroupBox1.Size = new System.Drawing.Size(240, 216);
179       this.GroupBox1.TabIndex = 10;
180       this.GroupBox1.TabStop = false;
181       this.GroupBox1.Text = "Email Editor";
182
183       this.cmdSend.Location = new System.Drawing.Point(80, 184);
184       this.cmdSend.Name = "cmdSend";
185       this.cmdSend.TabIndex = 8;
186       this.cmdSend.Text = "Send";
187       this.cmdSend.Click += new System.EventHandler(this.cmdSend_Click);
188
189       this.LabelMessage.AutoSize = true;
190       this.LabelMessage.Location = new System.Drawing.Point(16, 104);
191       this.LabelMessage.Name = "LabelMessage";
192       this.LabelMessage.Size = new System.Drawing.Size(50, 16);
193       this.LabelMessage.TabIndex = 7;
194       this.LabelMessage.Text = "Message";
195       this.LabelMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
196
197       this.LabelSubject.AutoSize = true;
198       this.LabelSubject.Location = new System.Drawing.Point(16, 74);
199       this.LabelSubject.Name = "LabelSubject";
200       this.LabelSubject.Size = new System.Drawing.Size(42, 16);
201       this.LabelSubject.TabIndex = 6;
202       this.LabelSubject.Text = "Subject";
203       this.LabelSubject.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
204
205       this.LabelSentTo.AutoSize = true;
206       this.LabelSentTo.Location = new System.Drawing.Point(16, 50);
207       this.LabelSentTo.Name = "LabelSentTo";
208       this.LabelSentTo.Size = new System.Drawing.Size(43, 16);
209       this.LabelSentTo.TabIndex = 5;
210       this.LabelSentTo.Text = "Send to";
211       this.LabelSentTo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
212
213       this.LabelMailFrom.AutoSize = true;
214       this.LabelMailFrom.Location = new System.Drawing.Point(16, 26);
215       this.LabelMailFrom.Name = "LabelMailFrom";
216       this.LabelMailFrom.Size = new System.Drawing.Size(51, 16);
217       this.LabelMailFrom.TabIndex = 4;
218       this.LabelMailFrom.Text = "Mail from";
219       this.LabelMailFrom.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
220
221       this.txtMessageText.Location = new System.Drawing.Point(80, 96);
222       this.txtMessageText.Multiline = true;
223       this.txtMessageText.Name = "txtMessageText";
224       this.txtMessageText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
225       this.txtMessageText.Size = new System.Drawing.Size(136, 80);
226       this.txtMessageText.TabIndex = 3;
227       this.txtMessageText.Text = "this is the\r\nmulti-line test\r\n";
228
229       this.txtMessageSubject.Location = new System.Drawing.Point(80, 72);
230       this.txtMessageSubject.Name = "txtMessageSubject";
231       this.txtMessageSubject.Size = new System.Drawing.Size(136, 20);
232       this.txtMessageSubject.TabIndex = 2;
233       this.txtMessageSubject.Text = "test message";
234
235       this.txtSendTo.Location = new System.Drawing.Point(80, 48);
236       this.txtSendTo.Name = "txtSendTo";
237       this.txtSendTo.Size = new System.Drawing.Size(136, 20);
238       this.txtSendTo.TabIndex = 1;
239       this.txtSendTo.Text = "info";
240
241       this.txtMailFrom.Location = new System.Drawing.Point(80, 24);
242       this.txtMailFrom.Name = "txtMailFrom";
243       this.txtMailFrom.Size = new System.Drawing.Size(136, 20);
244       this.txtMailFrom.TabIndex = 0;
245       this.txtMailFrom.Text = "test";
246
247       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
248       this.ClientSize = new System.Drawing.Size(512, 229);
249       this.Controls.Add(this.GroupBox2);
250       this.Controls.Add(this.GroupBox1);
251       this.Name = "frmMain";
252       this.Text = "Send Email";
253       this.Load += new System.EventHandler(this.frmMain_Load);
254       this.GroupBox2.ResumeLayout(false);
255       this.GroupBox1.ResumeLayout(false);
256       this.ResumeLayout(false);
257
258     }
259           
260     [STAThread]
261     static void Main() 
262     {
263       Application.Run(new frmMain());
264     }
265
266     private void cmdSend_Click(object sender, System.EventArgs e)
267     {
268             // send mail
269     }
270
271     private void frmMain_Load(object sender, System.EventArgs e)
272     {
273       cmbAuth.Items.Add("None");
274       cmbAuth.Items.Add("POP3");
275       cmbAuth.Items.Add("Login");
276       cmbAuth.Items.Add("Plain");
277       cmbAuth.SelectedIndex = 0;
278     }
279   }
280 }