/// <summary>
        /// 发送HTML邮件
        /// </summary>
        /// <param name="subject">主题</param>
        /// <param name="sendto">发送给</param>
        /// <param name="body">邮件主体</param>
        /// <param name="ccto">抄送 可选</param>
        /// <returns></returns>
        public bool SendHtmlMail(string subject, string sendto, string body, string ccto = "")
        {
            if (string.IsNullOrEmpty(subject))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(sendto))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(body))
            {
                return(false);
            }
            //邮件发送客户端
            MailClient mailClient = new MailClient(Host, Address, Passwd);
            //创建邮件对象
            MailMessageBuilder buildMsg = new MailMessageBuilder(Address, subject, sendto, body, true);
            MailMessage        msg      = buildMsg.Message();

            return(mailClient.Send(msg));
        }
Exemple #2
0
        /// <summary>
        /// 发送普通文本邮件
        /// </summary>
        /// <param name="subject">主题</param>
        /// <param name="sendto">发送给</param>
        /// <param name="text">邮件主体</param>
        /// <param name="ccto">抄送 可选</param>
        /// <returns></returns>
        public bool SendTextMail(string subject, string sendto, string text, string ccto = "")
        {
            if (string.IsNullOrEmpty(subject))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(sendto))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }
            //邮件发送客户端
            MailClient mailClient = new MailClient(Host, Account, Passwd, this.UseDefaultCredentials);
            //创建邮件对象
            MailMessageBuilder buildMsg = new MailMessageBuilder(Account, subject, sendto, text, false);
            MailMessage        msg      = buildMsg.Message();

            return(mailClient.Send(msg));
        }