Пример #1
0
        /// <summary>
        /// The send.
        /// </summary>
        /// <param name="sendMail">
        /// The send mail.
        /// </param>
        /// <param name="fromAddress">
        /// The from address.
        /// </param>
        /// <param name="toAddress">
        /// The to address.
        /// </param>
        /// <param name="subject">
        /// The subject.
        /// </param>
        /// <param name="bodyText">
        /// The body text.
        /// </param>
        /// <param name="bodyHtml">
        /// The body html.
        /// </param>
        public static void Send(
            [NotNull] this ISendMail sendMail,
            [NotNull] MailAddress fromAddress,
            [NotNull] MailAddress toAddress,
            [CanBeNull] string subject,
            [CanBeNull] string bodyText,
            [CanBeNull] string bodyHtml)
        {
            CodeContracts.VerifyNotNull(sendMail, "sendMail");
            CodeContracts.VerifyNotNull(fromAddress, "fromAddress");
            CodeContracts.VerifyNotNull(toAddress, "toAddress");

            var mailMessage = new MailMessage();

            mailMessage.Populate(fromAddress, toAddress, subject, bodyText, bodyHtml);
            sendMail.SendAll(new List <MailMessage> {
                mailMessage
            });
        }