Exemplo n.º 1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            btnSend.Enabled           = false;
            btnSend.Text              = "Sending";
            pictureBoxLoading.Visible = true;
            Task.Run(() =>
            {
                try
                {
                    var mailSender = new MailSender(_parentForm.ServerInfo.SmtpServer, _parentForm.ServerInfo.SmtpPort
                                                    , true, _username, _password);
                    mailSender.Connect();
                    var sentEmail = mailSender.Send(tbFrom.Text, tbTo.Text, tbSubject.Text, tbBody.Text, Attachments);

                    mailSender.Disconnect();

                    _parentForm.MailReceiver.SentFolder.Append(sentEmail);
                }
                catch (Exception ex)
                {
                    _parentForm.Invoke((Action)(() => MessageBox.Show(ex.Message, "Sending failed")));
                    this.Invoke((Action)(() => pictureBoxLoading.Visible = false));
                }

                this.Invoke((Action)(() => pictureBoxLoading.Visible = false));
                this.Invoke((Action)(() => this.Close()));
            });
        }
Exemplo n.º 2
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            Message    msg = new Message(currentuser.Email, ToBox.Text, BodyBox.Text, ThemeBox.Text);
            MailSender ms  = new MailSender(mailservice, currentuser);

            IncludeAttachments(msg);
            messagelist.Add(msg);

            Task send = new Task(() => ms.Send(msg));

            try
            {
                send.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 3
0
        public void Handle(string toAddress)
        {
            MailSender mailsender = new MailSender();

            mailsender.Send(toAddress, "This is non-ninject example.");
        }