Exemplo n.º 1
0
 private void SendMail()
 {
     Classes SendNewMail = new Classes(MainApplication.MessageToSend, SecurePassword);
     SecurePassword.Dispose();
     if (SendNewMail.SendMail())
         this.Close();
     else
     {
         this.Button.Enabled = true;
         this.label.Text = "An error occured while sending, do you want to try again?";
     }
 }
 private void SaveMessage_Click(object sender, EventArgs e)
 {
     if (MessageLocation != "")
     {
         MailMessage SaveMessage = new MailMessage();
         MailAddress ToAddress = new MailAddress(this.ToEmailAddress.Text);
         SaveMessage.To.Add(ToAddress);
         MailAddress CCAddress = new MailAddress(this.CCAddress.Text);
         SaveMessage.CC.Add(CCAddress);
         SaveMessage.Subject = this.SubjectContent.Text;
         SaveMessage.Body = this.MainInput.Text;
         Classes SaveMessageToFile = new Classes(SaveMessage);
         if (SaveMessageToFile.SaveEmailMessage(MessageLocation))
             MessageBox.Show("File got saved succesfully");
     }
     else
     {
         DialogResult SaveFileResult = new DialogResult();
         SaveFileResult = SaveMessageDialog.ShowDialog();
         if (SaveFileResult != DialogResult.Cancel)
         {
             MailMessage SaveMessage = new MailMessage();
             MailAddress ToAddress = new MailAddress(this.ToEmailAddress.Text);
             SaveMessage.To.Add(ToAddress);
             MailAddress CCAddress = new MailAddress(this.CCAddress.Text);
             SaveMessage.CC.Add(CCAddress);
             SaveMessage.Subject = this.SubjectContent.Text;
             SaveMessage.Body = this.MainInput.Text;
             Classes SaveMessageToFile = new Classes(SaveMessage);
             if (SaveMessageToFile.SaveEmailMessage(SaveMessageDialog.FileName))
                 MessageBox.Show("File got saved succesfully");
             MessageLocation = SaveMessageDialog.FileName;
         }
     }
 }
 public MainApplication()
 {
     InitializeComponent();
     Classes something = new Classes();
 }
        private void OpenFile_Click(object sender, EventArgs e)
        {
            DialogResult OpenMessageResults = new DialogResult();
            OpenMessageResults = OpenMessage.ShowDialog();
            if (OpenMessageResults != DialogResult.Cancel)
            {
                ToEmailAddress.Text = "";
                CCAddress.Text = "";
                SubjectContent.Text = "";
                MainInput.Text = "";

                Classes OpenMessageClass = new Classes();
                MailMessage MessageOpened = OpenMessageClass.OpenMessage(OpenMessage.FileName);

                this.ToEmailAddress.Text = MessageOpened.To.ToString();
                this.CCAddress.Text = MessageOpened.CC.ToString();
                this.SubjectContent.Text = MessageOpened.Subject;
                this.MainInput.Text = MessageOpened.Body;

                if (MessageOpened.IsBodyHtml)
                    this.SendAsHtml.Checked = true;
                else
                    this.SendAsTextOnly.Checked = true;
            }
        }