private MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();

            mailSendStatus.IsSended = false;
            int flag = 0;
            if (mailContent.MailingAdress == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                flag = 1;
            }
            if (mailContent.PlainText == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                flag = 1;
            }
            if (login == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Login ";
                flag = 1;
            }
            if (password == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Password ";
                flag = 1;
            }

            if (flag == 0)
            {
                SmtpClient smtpclient = new SmtpClient();

                try
                {
                    var _with1 = (smtpclient);
                    _with1.Host = "Smtp.mail.ru";
                    _with1.Port = 25;
                    _with1.EnableSsl = false;
                    _with1.Credentials = new NetworkCredential(login, password);

                    MailMessage mailMessage = new MailMessage(login + "@mail.ru", mailContent.MailingAdress, mailContent.Subject, mailContent.HtmlText);
                    mailMessage.IsBodyHtml = isBodyHtml;

                    mailMessage.Body = mailContent.HtmlText;

                    smtpclient.Send(mailMessage);
                    mailSendStatus.IsSended=true;
                }
                catch (Exception ex)
                {
                    mailSendStatus.ErrorType = mailSendStatus.ErrorType + ex;
                }
            }
            return mailSendStatus;
        }
Ejemplo n.º 2
0
        public MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();

            if (String.IsNullOrEmpty(mailContent.MailingAdress))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                return(mailSendStatus);
            }
            if (String.IsNullOrEmpty(mailContent.HtmlText))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                return(mailSendStatus);
            }

            SmtpClient smtpClient = new SmtpClient(host);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(mailContent.MailFrom);

            if (!String.IsNullOrEmpty(mailContent.ReplyToAddress))
            {
                mail.ReplyToList.Add(mailContent.ReplyToAddress);
            }


            mail.To.Add(mailContent.MailingAdress);

            mail.Subject = mailContent.Subject;

            if (!String.IsNullOrEmpty(mailContent.HtmlText))
            {
                ContentType   mimeType  = new System.Net.Mime.ContentType("text/html");
                AlternateView alternate = AlternateView.CreateAlternateViewFromString(mailContent.HtmlText, mimeType);
                mail.AlternateViews.Add(alternate);
            }

            mail.Body = mailContent.PlainText;

            if (mailContent.AttachmentPass != null)
            {
                mail.Attachments.Add(new Attachment(mailContent.AttachmentPass));
            }

            smtpClient.Send(mail);

            mailSendStatus.IsSended = true;

            return(mailSendStatus);
        }
        public MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();
            if (String.IsNullOrEmpty(mailContent.MailingAdress))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                return mailSendStatus;
            }
            if (String.IsNullOrEmpty(mailContent.HtmlText))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                return mailSendStatus;
            }

            SmtpClient smtpClient = new SmtpClient(host);

            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(mailContent.MailFrom);

            if (!String.IsNullOrEmpty(mailContent.ReplyToAddress))
            {
                mail.ReplyToList.Add(mailContent.ReplyToAddress);
            }

            mail.To.Add(mailContent.MailingAdress);

            mail.Subject = mailContent.Subject;

            if (!String.IsNullOrEmpty(mailContent.HtmlText))
            {
                ContentType mimeType = new System.Net.Mime.ContentType("text/html");
                AlternateView alternate = AlternateView.CreateAlternateViewFromString(mailContent.HtmlText, mimeType);
                mail.AlternateViews.Add(alternate);
            }

            mail.Body = mailContent.PlainText;

            if (mailContent.AttachmentPass != null)
                mail.Attachments.Add(new Attachment(mailContent.AttachmentPass));

            smtpClient.Send(mail);

            mailSendStatus.IsSended = true;

            return mailSendStatus;
        }
Ejemplo n.º 4
0
               private MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
               
        {
                       MailSendStatus mailSendStatus = new MailSendStatus();

                       mailSendStatus.IsSended = false;
                       int flag = 0;

                       if(mailContent.MailingAdress == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                               flag = 1;
                               
            }

                       if(mailContent.PlainText == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                               flag = 1;
                               
            }

                       if(login == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Login ";
                               flag = 1;
                               
            }

                       if(password == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Password ";
                               flag = 1;
                               
            }

                       if(flag == 0)
                       
            {
                               SmtpClient smtpclient = new SmtpClient();

                               try
                                {
                                       var _with1         = (smtpclient);
                                       _with1.Host        = "Smtp.mail.ru";
                                       _with1.Port        = 25;
                                       _with1.EnableSsl   = false;
                                       _with1.Credentials = new NetworkCredential(login, password);

                    MailMessage mailMessage = new MailMessage(login + "@mail.ru", mailContent.MailingAdress, mailContent.Subject, mailContent.HtmlText);

                    mailMessage.IsBodyHtml = isBodyHtml;

                    mailMessage.Body = mailContent.HtmlText;

                    smtpclient.Send(mailMessage);
                                       mailSendStatus.IsSended = true;
                                   
                }
                               catch(Exception ex)
                               
                {
                                       mailSendStatus.ErrorType = mailSendStatus.ErrorType + ex;
                                   
                }

                           
            }

                       return mailSendStatus;
                               
        }