Ejemplo n.º 1
0
        public void Send(MailWindow Page, User user, ConfigModel cfg, string to, string subject, string msg)
        {
            var message = new MimeMessage();

            message.From.Add(new MailboxAddress(user.Mail));
            message.To.Add(new MailboxAddress(to));
            message.Subject = subject;
            var Body = new BodyBuilder();

            Body.HtmlBody = msg;
            foreach (var attachment in Message.AttachmentList)
            {
                Body.Attachments.Add(attachment);
            }
            message.Body = Body.ToMessageBody();

            using (SmtpClient client = new SmtpClient())
            {
                try
                {
                    client.Connect(cfg.SmtpServer, cfg.SmtpPort);
                    client.Authenticate(user.Mail, user.Password);
                    client.Send(message);
                    client.Disconnect(true);
                }
                catch (MailKit.Net.Smtp.SmtpCommandException)
                {
                    info inf = new info("Message Could not be Sent \n\r Maybe you are trying to send to much attachments");
                    inf.ShowDialog();
                }
            }
        }
Ejemplo n.º 2
0
        private void SendMail(object sender, RoutedEventArgs e)
        {
            if (To.Text != "" && Subject.Text != "")
            {
                try
                {
                    string body = "<body style='" +
                                  "font-family:" + FontList.SelectedItem.ToString() + ";" +
                                  "font-size:" + FontSize.SelectedItem + "';" +
                                  "color:" + ClrPicker_Font.SelectedColorText + ";>"
                                  + SendBody.Text +
                                  "</body>";
                    new SendMail().Send(Window, UserData, Config, To.Text, Subject.Text, body);

                    info inf = new info("Message Has Been Sent to: " + To.Text);
                    inf.ShowDialog();
                    Subject.Text  = "";
                    To.Text       = "";
                    SendBody.Text = "";
                    Window.MainFrame.NavigationService.GoBack();
                }
                catch (Exception exce)
                {
                    info inf = new info("Message Could not be Sent \n\r");
                    inf.ShowDialog();
                }
            }
            else
            {
                info inf = new info("Fields Cannot be empty");
                inf.ShowDialog();
            }
        }
Ejemplo n.º 3
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            info info = new info();

            info.ShowDialog();
        }
 private void toolStripButton4_Click(object sender, EventArgs e)
 {
     info info = new info();
     info.ShowDialog();
 }