Пример #1
0
        /// <summary>
        ///     Sends async the given email
        /// </summary>
        /// <param name="mail">The mail message to send.</param>
        public async Task<IMailAttributes> DeliverAsync(IMailAttributes mail)
        {
            if (mail == null)
                throw new ArgumentNullException("mail");

            var mailContext = new MailSendingContext(mail);
            _interceptor.OnMailSending(mailContext);

            if (mailContext.Cancel)
                return null;

            Task<IMailAttributes> sendtask = _sender.SendAsync(mail);
            await sendtask.ContinueWith(t => AsyncSendCompleted(t.Result));
            return mail;
        }
Пример #2
0
        /// <summary>
        ///     Sends the given email
        /// </summary>
        /// <param name="mail">The mail message to send.</param>
        public IMailAttributes Deliver(IMailAttributes mail)
        {
            if (mail == null)
                throw new ArgumentNullException("mail");

            var mailContext = new MailSendingContext(mail);
            _interceptor.OnMailSending(mailContext);

            if (mailContext.Cancel)
                return null;

            _sender.Send(mail);
            _interceptor.OnMailSent(mail);

            return mail;
        }