コード例 #1
0
 public static void TrySend(this ISendMail sender, IEmailMessage message)
 {
     if (sender != null)
     {
         sender.Send(message);
     }
 }
コード例 #2
0
        public void SendWelcome(string email, string username)
        {
            var content = MailContent();

            content = content.Replace("{USER}", username);
            _mailService.Send(email, MailConst.From.DO_NOT_REPLAY, content, true);
        }
コード例 #3
0
 public async Task Handle(Notification notification, CancellationToken cancellationToken)
 {
     await _sendMail.Send(new DTOs.EMailMessage {
         To      = "*****@*****.**",
         Subject = "Cadastro de Paciente",
         Body    = $"Cadastro e novo paciente: {notification.ToString()}"
     });
 }
コード例 #4
0
 public void Send(ISendMail mailSender)
 {
     if (mailSender == null)
     {
         throw new ArgumentNullException("mailSender");
     }
     mailSender.Send(Build());
 }
コード例 #5
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>
 public static void Send(
     [NotNull] this ISendMail sendMail,
     [NotNull] MailAddress fromAddress,
     [NotNull] MailAddress toAddress,
     [CanBeNull] string subject,
     [CanBeNull] string bodyText)
 {
     sendMail.Send(fromAddress, toAddress, subject, bodyText, null);
 }
コード例 #6
0
        /// <summary>
        /// The send.
        /// </summary>
        /// <param name="sendMail">
        /// The send Mail.
        /// </param>
        /// <param name="fromEmail">
        /// The from email.
        /// </param>
        /// <param name="toEmail">
        /// The to email.
        /// </param>
        /// <param name="subject">
        /// The subject.
        /// </param>
        /// <param name="body">
        /// The body.
        /// </param>
        public static void Send(
            [NotNull] this ISendMail sendMail,
            [NotNull] string fromEmail,
            [NotNull] string toEmail,
            [CanBeNull] string subject,
            [CanBeNull] string body)
        {
            CodeContracts.VerifyNotNull(fromEmail, "fromEmail");
            CodeContracts.VerifyNotNull(toEmail, "toEmail");

            sendMail.Send(new MailAddress(fromEmail), new MailAddress(toEmail), subject, body);
        }
コード例 #7
0
 /// <summary>
 /// The send.
 /// </summary>
 /// <param name="sendMail">
 /// The send mail.
 /// </param>
 /// <param name="fromEmail">
 /// The from email.
 /// </param>
 /// <param name="fromName">
 /// The from name.
 /// </param>
 /// <param name="toEmail">
 /// The to email.
 /// </param>
 /// <param name="toName">
 /// The to name.
 /// </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] string fromEmail,
     [CanBeNull] string fromName,
     [NotNull] string toEmail,
     [CanBeNull] string toName,
     [CanBeNull] string subject,
     [CanBeNull] string bodyText,
     [CanBeNull] string bodyHtml)
 {
     sendMail.Send(new MailAddress(fromEmail, fromName), new MailAddress(toEmail, toName), subject, bodyText, bodyHtml);
 }
コード例 #8
0
 public async Task SendEmailAsync(string email, string subject, string htmlMessage)
 {
     var model = new MailModel
     {
         CcEmail = _mailoptions.UsernameEmail,
         Content = htmlMessage,
         From    = _mailoptions.UsernameEmail,
         Subject = "Stuffpacker - " + subject,
         To      = new[] { email }
     };
     await _sendmail.Send(model);
 }
コード例 #9
0
ファイル: MailGateWay.cs プロジェクト: zzz1985xxxwl/bjl_hrmis
 public void Send(MailBody mailBody, bool addLoginAddress)
 {
     _MailFilter = new MailFilter();
     InitMail(mailBody, addLoginAddress);
     if (_MailBody.MailTo != null && _MailBody.MailTo.Count > 0)
     {
         string error = _SendMail.Send(_MailBody, MailConfig.MailSet);
         if (!string.IsNullOrEmpty(error))
         {
             throw new ApplicationException(error);
         }
     }
 }
コード例 #10
0
        public void Handle(SendEmailMessageCommand command)
        {
            // get a fresh email address from the database
            EmailMessage emailMessage = null;

            while (emailMessage == null && ++_retryCount < RetryLimit)
            {
                if (_retryCount > 1)
                {
                    Thread.Sleep(300);
                }

                var person = _entities.Get <Person>()
                             .EagerLoad(_entities, new Expression <Func <Person, object> >[]
                {
                    p => p.Messages,
                })
                             .SingleOrDefault(x => x.RevisionId == command.PersonId);
                emailMessage = person != null
                    ? person.Messages.SingleOrDefault(x => x.Number == command.MessageNumber) : null;
            }
            if (emailMessage == null)
            {
                var exception = new OperationCanceledException(string.Format(
                                                                   "Unable to locate EmailMessage number '{0}' for person '{1}'. The message send operation was canceled after {2} retries.",
                                                                   command.MessageNumber, command.PersonId, _retryCount));
                _exceptionLogger.Log(exception);
                throw exception;
            }

            // convert email message to mail message
            var mail = _queryProcessor.Execute(
                new ComposeMailMessage(emailMessage)
                );

            // send the mail message
            _mailSender.Send(mail);

            // log when the message was sent
            emailMessage.SentOnUtc = DateTime.UtcNow;
            _entities.Update(emailMessage);
        }
コード例 #11
0
        // POST: api/EmailManager
        public IHttpActionResult Post([FromBody] SendMailDTO dto)
        {
            Thread.Sleep(2000);
            log.Debug("Invio mail...");
            try
            {
                var mailingLists = mailingListRepository.Get(dto.IdListeDestinatarie);
                var destinatari  = mailingLists.SelectMany(ml => ml.Emails).Distinct().ToArray();
                var email        = new Email(new string[0], new string[0], destinatari, dto.Oggetto, dto.Corpo);

                mailSender.Send(email);
            }
            catch (Exception ex)
            {
                log.ErrorFormat("L'invio della mail non è stato completato per i seguente errore :\n Error: {0}\n Description: {1}", ex.HResult, ex.Message);
                throw;
            }

            log.Debug("Mail inviate");

            return(Ok(new { id = dto.IdListeDestinatarie }));
        }
コード例 #12
0
 public void Send(ISendMail mailSender)
 {
     if (mailSender == null) throw new ArgumentNullException("mailSender");
     mailSender.Send(Build());
 }
コード例 #13
0
        public IDataResult <MailRequest> SendMail(MailRequest mailRequest)
        {
            var result = _sendMail.Send(mailRequest.ToEmail, mailRequest.Subject, mailRequest.Body);

            return(new SuccessDataResult <MailRequest>(result, "Mail gönderildi."));
        }
コード例 #14
0
        public void SendMail(string username, string password, string email)
        {
            var content = MailContent(username, password);

            _sendMail.Send(email, "You Forgot Your Password", content, true);
        }