Ejemplo n.º 1
0
        public bool    Send(EMailInfo eMailInfo)
        {
            MailMessage mm = new MailMessage(eMailInfo.From, eMailInfo.To);

            mm.Subject    = eMailInfo.Subject;
            mm.Body       = eMailInfo.Body;
            mm.IsBodyHtml = false;

            //Login and Sending
            SmtpClient sc = new SmtpClient(eMailInfo.SMTPClient, eMailInfo.Port);

            sc.EnableSsl             = true;
            sc.DeliveryMethod        = SmtpDeliveryMethod.Network;
            sc.UseDefaultCredentials = false;
            sc.Credentials           = new NetworkCredential(eMailInfo.Sender, eMailInfo.Password);
            try
            {
                sc.Send(mm);
            }
            catch (Exception exc)
            {
                Status    = exc.Message;
                ErrorInfo = exc.StackTrace;
                return(false);
            }
            Status = "Ok";
            return(true);
        }
Ejemplo n.º 2
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            EMailInfo info = new EMailInfo();

            info.Sender     = cbFrom.Text;
            info.Body       = tbBody.Text;
            info.Password   = pbPassword.Password;
            info.Port       = int.Parse(tbPort.Text);
            info.SMTPClient = tbServer.Text;
            info.Subject    = tbSubject.Text;
            info.From       = cbFrom.Text;
            info.To         = cbTo.Text;
            EmailSendServiceClass emailSendServiceClass = new EmailSendServiceClass();

            emailSendServiceClass.Send(info);
            tbLog.Text += DateTime.Now + "r\n";
            tbLog.Text += emailSendServiceClass.Status + Environment.NewLine;
            tbLog.Text += emailSendServiceClass.ErrorInfo + Environment.NewLine;
        }