tmp/test-doxy-mms/MarekMailSystem/MarekMailSystem2SimpleWinUI/FormMarekMailSystem2SimpleWinUI.cs

Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.ComponentModel;
00004 using System.Data;
00005 using System.Drawing;
00006 using System.Text;
00007 using System.Windows.Forms;
00008 using MarekMailSystem2;
00009 
00010 namespace MarekMailSystem2SimpleWinUI
00011 {
00012     public partial class FormMarekMailSystem2SimpleWinUI : Form
00013     {
00014         public FormMarekMailSystem2SimpleWinUI()
00015         {
00016             InitializeComponent();
00017         }
00018 
00019         private void buttonAtt1_Click(object sender, EventArgs e)
00020         {
00021             if (openFileDialogAtt.ShowDialog() == DialogResult.OK)
00022                 textBoxAtt1.Text = openFileDialogAtt.FileName;
00023         }
00024 
00025         private void buttonReset_Click(object sender, EventArgs e)
00026         {
00027             MessageBox.Show("TODO: later..");
00028         }
00029 
00030         private void buttonSend_Click(object sender, EventArgs e)
00031         {
00032             string from = textBoxFrom.Text;
00033             string to = textBoxTo.Text;
00034             string cc = textBoxCc.Text;
00035             string bcc = textBoxBcc.Text;
00036             string subject = textBoxSubject.Text;
00037             string body = textBoxBody.Text;
00038             bool html = checkBoxHtml.Checked;
00039             string att1 = textBoxAtt1.Text;
00040             string att2 = textBoxAtt2.Text;
00041             string att3 = textBoxAtt3.Text;
00042             Email email;
00043             if (checkBoxFromFromConf.Checked)
00044                 email = new Email(to, subject, body);
00045             else
00046                 email = new Email(from, to, subject, body);
00047             email.Cc = cc;
00048             email.Bcc = bcc;
00049             email.IsBodyHtml = html;
00050             if (att1 != "") email.FileAttachments.Add(att1);
00051             if (att2 != "") email.FileAttachments.Add(att2);
00052             if (att3 != "") email.FileAttachments.Add(att3);
00053             // TODO: is != "" optimal? I don't see anything like string.IsEmpty...
00054             // email is now ready.
00055 
00056             SmtpEmailSender client = new SmtpEmailSender();
00057             if (!checkBoxSmtpFromConf.Checked)
00058             {
00059                 string userName = textBoxUserName.Text;
00060                 string password = textBoxPassword.Text;
00061                 string host = textBoxHost.Text;
00062                 int port = Int32.Parse(textBoxPort.Text);
00063                 bool ssl = checkBoxSsl.Checked;
00064 
00065                 client.UserName = userName;
00066                 client.Password = password;
00067                 client.Host = host;
00068                 client.Port = port;
00069                 client.Ssl = ssl;
00070             }
00071 
00072             client.Send(email);
00073 
00074             MessageBox.Show(email.SendingStatus.ToString(),"Email status");
00075         }
00076 
00077         private void buttonAtt2_Click(object sender, EventArgs e)
00078         {
00079             if (openFileDialogAtt.ShowDialog() == DialogResult.OK)
00080                 textBoxAtt2.Text = openFileDialogAtt.FileName;
00081 
00082         }
00083 
00084         private void buttonAtt3_Click(object sender, EventArgs e)
00085         {
00086             if (openFileDialogAtt.ShowDialog() == DialogResult.OK)
00087                 textBoxAtt3.Text = openFileDialogAtt.FileName;
00088         }
00089 
00090         private void checkBoxSmtpFromConf_CheckedChanged(object sender, EventArgs e)
00091         {
00092             if (checkBoxSmtpFromConf.Checked)
00093             {
00094                 textBoxHost.Enabled = false;
00095                 textBoxPassword.Enabled = false;
00096                 textBoxPort.Enabled = false;
00097                 textBoxUserName.Enabled = false;
00098                 checkBoxSsl.Enabled = false;
00099             }
00100             else
00101             {
00102                 textBoxHost.Enabled = true;
00103                 textBoxPassword.Enabled = true;
00104                 textBoxPort.Enabled = true;
00105                 textBoxUserName.Enabled = true;
00106                 checkBoxSsl.Enabled = true;
00107             }
00108         }
00109 
00110         private void checkBoxFromFromConf_CheckedChanged(object sender, EventArgs e)
00111         {
00112             if (checkBoxFromFromConf.Checked)
00113                 textBoxFrom.Enabled = false;
00114             else
00115                 textBoxFrom.Enabled = true;
00116         }
00117     }
00118 }

Generated on Thu Oct 25 11:32:52 2007 for Marek Mail System by  doxygen 1.5.3-20071008