Beispiel #1
0
        public static bool SendOK(string MailTo, string MailSubject, string MailBody, bool IsHtml, string MailFrom, string MailFromName, string MailPwd, string MailSmtpHost, int MailSmtpPort)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.MaxRecipientNum = 80;
            mailMessage.From            = ConfigurationManager.AppSettings["Lottery:WebmasterEmail"];
            mailMessage.FromName        = MailFromName;
            string str = MailTo;

            char[] chArray = new char[1] {
                ','
            };
            foreach (string recipient in str.Split(chArray))
            {
                mailMessage.AddRecipients(recipient);
            }
            mailMessage.Subject    = MailSubject;
            mailMessage.BodyFormat = !IsHtml ? MailFormat.Text : MailFormat.HTML;
            mailMessage.Priority   = MailPriority.Normal;
            mailMessage.Body       = MailBody;
            SmtpClient smtpClient = new SmtpClient(MailSmtpHost, MailSmtpPort);

            if (smtpClient.Send(mailMessage, MailFrom, MailPwd))
            {
                return(true);
            }
            MailHelp.SaveErrLog(MailTo, MailFrom, MailFromName, MailSmtpHost, smtpClient.ErrMsg);
            return(false);
        }
Beispiel #2
0
        public static bool SendOK(string MailTo, string MailSubject, string MailBody, bool IsHtml, string MailFrom, string MailFromName, string MailPwd, string MailSmtpHost, int MailSmtpPort)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.MaxRecipientNum = 80;
            mailMessage.From            = ConfigurationManager.AppSettings["Lottery:WebmasterEmail"];
            mailMessage.FromName        = MailFromName;
            string[] array = MailTo.Split(new char[]
            {
                ','
            });
            for (int i = 0; i < array.Length; i++)
            {
                mailMessage.AddRecipients(array[i]);
            }
            mailMessage.Subject = MailSubject;
            if (IsHtml)
            {
                mailMessage.BodyFormat = MailFormat.HTML;
            }
            else
            {
                mailMessage.BodyFormat = MailFormat.Text;
            }
            mailMessage.Priority = MailPriority.Normal;
            mailMessage.Body     = MailBody;
            SmtpClient smtpClient = new SmtpClient(MailSmtpHost, MailSmtpPort);

            if (smtpClient.Send(mailMessage, MailFrom, MailPwd))
            {
                return(true);
            }
            MailHelp.SaveErrLog(MailTo, MailFrom, MailFromName, MailSmtpHost, smtpClient.ErrMsg);
            return(false);
        }