Exemple #1
0
        /// <summary>
        /// Sends mail async.
        /// </summary>
        /// <param name="fromAddress">From email address.</param>
        /// <param name="subject">Subject.</param>
        /// <param name="message">Message.</param>
        /// <param name="bodyHtml">Sets message is HTML.</param>
        /// <param name="userToken">User token for async.</param>
        /// <param name="sendToAddress">Send to email address.</param>
        public void SendMailAsync(EmailAddress fromAddress, string subject, string message, bool bodyHtml, object userToken, EmailAddress sendToAddress)
        {
            Encapsulation.TryValidateParam <ArgumentNullException>(fromAddress.IsNotNull(), nameof(fromAddress));
            Encapsulation.TryValidateParam(subject, nameof(subject));
            Encapsulation.TryValidateParam(message, nameof(message));
            Encapsulation.TryValidateParam <ArgumentNullException>(sendToAddress.IsNotNull(), nameof(sendToAddress));

            // 'Set default types, just in case.
            sendToAddress.EmailAddressType = EmailAddressType.SendTo;

            this.SendMailAsync(fromAddress, subject, message, bodyHtml, userToken, sendToAddress);
        }
Exemple #2
0
        /// <summary>
        /// Sends mail async.
        /// </summary>
        /// <param name="fromAddress">From email address.</param>
        /// <param name="subject">Subject.</param>
        /// <param name="message">Message.</param>
        /// <param name="bodyHtml">Sets message is HTML.</param>
        /// <param name="sendAddresses">Send to email addresses.</param>
        public async Task SendMailAsync(EmailAddress fromAddress, string subject, string message, bool bodyHtml, EmailAddress[] sendAddresses)
        {
            Encapsulation.TryValidateParam <ArgumentNullException>(fromAddress.IsNotNull(), nameof(fromAddress));
            Encapsulation.TryValidateParam(subject, nameof(subject));
            Encapsulation.TryValidateParam(message, nameof(message));
            Encapsulation.TryValidateParam(sendAddresses, nameof(sendAddresses));

            // 'Set default types, just in case.
            fromAddress.EmailAddressType = EmailAddressType.SendFrom;

            using (var tempMessage = CreateMailMessage(fromAddress, subject, message, bodyHtml, sendAddresses))
            {
                await this._mailServer.SendMailAsync(tempMessage).ConfigureAwait(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends mail.
        /// </summary>
        /// <param name="fromAddress">From email address.</param>
        /// <param name="subject">Subject.</param>
        /// <param name="message">Message.</param>
        /// <param name="bodyHtml">Sets message is HTML.</param>
        /// <param name="sendAddresses">Send email addresses.</param>
        public void SendMail(EmailAddress fromAddress, string subject, string message, bool bodyHtml, EmailAddress[] sendAddresses)
        {
            Encapsulation.TryValidateParam <ArgumentNullException>(fromAddress.IsNotNull(), nameof(fromAddress));
            Encapsulation.TryValidateParam(subject, nameof(subject));
            Encapsulation.TryValidateParam(message, nameof(message));
            Encapsulation.TryValidateParam(sendAddresses, nameof(sendAddresses));

            // 'Set default types, just in case.
            fromAddress.EmailAddressType = EmailAddressType.SendFrom;

            using (var tempMessage = CreateMailMessage(fromAddress, subject, message, bodyHtml, sendAddresses))
            {
                this.SendMailMessage(tempMessage, null);
            }
        }