mailclient.cs 12 KB

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