コード例 #1
0
ファイル: SmtpMail.cs プロジェクト: windygu/mysoftsolution
        /// <summary>
        /// 发送邮件到指定邮箱
        /// </summary>
        /// <param name="title"></param>
        /// <param name="body"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public void SendAsync(string title, string body, string[] to)
        {
            lock (lockObject)
            {
                if (isSystemMail)
                {
                    body += string.Format("<br/><br/>系统邮件,请勿直接回复!<span style=\"font-size:12px;\">({0})</span>", DateTime.Now);
                }
                SMTP smtp = new SMTP(this.mailFrom, to, title, body, this.smtpServer, userName, password);
                smtp.SMTPPort       = this.smtpPort;
                smtp.MailDisplyName = this.displayName;
                smtp.IsBodyHtml     = true;

                //启用线程池来实现异步发送
                AsyncMailSender sender = new AsyncMailSender(mail => mail.SendAsync());
                IAsyncResult    result = sender.BeginInvoke(smtp, ar =>
                {
                    AsyncMailSender handler = ar.AsyncState as AsyncMailSender;
                    if (handler != null)
                    {
                        handler.EndInvoke(ar);
                    }
                }, sender);
            }
        }
コード例 #2
0
ファイル: SmtpMail.cs プロジェクト: windygu/mysoftsolution
        /// <summary>
        /// 发送邮件到指定邮箱
        /// </summary>
        /// <param name="title"></param>
        /// <param name="body"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public SendResult Send(string title, string body, string[] to)
        {
            lock (lockObject)
            {
                if (isSystemMail)
                {
                    body += string.Format("<br/><br/>系统邮件,请勿直接回复!<span style=\"font-size:12px;\">({0})</span>", DateTime.Now);
                }
                SMTP smtp = new SMTP(this.mailFrom, to, title, body, this.smtpServer, userName, password);
                smtp.SMTPPort       = this.smtpPort;
                smtp.MailDisplyName = this.displayName;
                smtp.IsBodyHtml     = true;

                return(smtp.Send());
            }
        }
コード例 #3
0
        /// <summary>
        /// 发送邮件到指定邮箱
        /// </summary>
        /// <param name="title"></param>
        /// <param name="body"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public void SendAsync(string title, string body, string[] to)
        {
            lock (lockObject)
            {
                if (isSystemMail) body += string.Format("<br/><br/>系统邮件,请勿直接回复!<span style=\"font-size:12px;\">({0})</span>", DateTime.Now);
                SMTP smtp = new SMTP(this.mailFrom, to, title, body, this.smtpServer, userName, password);
                smtp.SMTPPort = this.smtpPort;
                smtp.MailDisplyName = this.displayName;
                smtp.IsBodyHtml = true;

                //启用线程池来实现异步发送
                AsyncMailSender sender = new AsyncMailSender(mail => mail.SendAsync());
                IAsyncResult result = sender.BeginInvoke(smtp, ar =>
                {
                    AsyncMailSender handler = ar.AsyncState as AsyncMailSender;
                    if (handler != null)
                    {
                        handler.EndInvoke(ar);
                    }
                }, sender);
            }
        }
コード例 #4
0
        /// <summary>
        /// 发送邮件到指定邮箱
        /// </summary>
        /// <param name="title"></param>
        /// <param name="body"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public SendResult Send(string title, string body, string[] to)
        {
            lock (lockObject)
            {
                if (isSystemMail) body += string.Format("<br/><br/>系统邮件,请勿直接回复!<span style=\"font-size:12px;\">({0})</span>", DateTime.Now);
                SMTP smtp = new SMTP(this.mailFrom, to, title, body, this.smtpServer, userName, password);
                smtp.SMTPPort = this.smtpPort;
                smtp.MailDisplyName = this.displayName;
                smtp.IsBodyHtml = true;

                return smtp.Send();
            }
        }