コード例 #1
0
        /// <summary>
        /// Sends the email.
        /// </summary>
        /// <param name="report">The report.</param>
        private void SendEmail(ProblemReport report)
        {
            if (report == null)
            {
                throw new ArgumentNullException("report");
            }

            using (var email = new MailMessage())
            {
                foreach (WebAuthor author in report.WebAuthors)
                {
                    email.To.Add(new MailAddress(author.EmailAddress, author.Name));
                }

                email.Subject = report.SubjectLine();

                BuildEmailBody(report, email);

                CustomiseEmail(email);

                using (var smtp = new SmtpClient())
                {
                    try
                    {
                        smtp.Send(email);
                    }
                    catch (SmtpException e)
                    {
                        throw e;
                    }
                }
            }
        }
コード例 #2
0
        private static void BuildEmailBody(ProblemReport report, MailMessage email)
        {
            var html = new StringBuilder("<div style=\"font-family:Arial\">");

            html.Append(report.MessageHtml.Replace("<h2>", "<h2 style=\"font-size:1.1em\">"));
            html.Append("</div>");
            email.IsBodyHtml = true;
            email.Body       = html.ToString();
        }
コード例 #3
0
        /// <summary>
        /// Receive a new report and send it by email
        /// </summary>
        /// <param name="report">The report.</param>
        public void ReportPublished(ProblemReport report)
        {
            var method = new SendEmailDelegate(SendEmail);

            method.BeginInvoke(report, null, null);
        }