Beispiel #1
0
 public async Task <bool> Handle(SendEmailComand command)
 {
     using (var client = new SmtpClient(_emailConfige.Host, _emailConfige.Port)
     {
         Credentials = new NetworkCredential(_emailConfige.Sender, _emailConfige.Password),
         EnableSsl = true
     })
         using (var message = new MailMessage(_emailConfige.Sender, command.To, command.Subject, command.Body))
         {
             await client.SendMailAsync(message);
         }
     return(true);
 }
Beispiel #2
0
        public async Task <IActionResult> ContactUs(string contactName, string emailAddress)
        {
            var thankYou = new SendEmailComand()
            {
                To      = emailAddress,
                Subject = "Thank you",
                Body    = "We will contact with you"
            };

            await _queueCommunicator.SendAsync(thankYou);

            var adminEmail = new SendEmailComand()
            {
                To      = "[email protected] ",
                Subject = "New Contact",
                Body    = $"{contactName} {emailAddress}"
            };

            await _queueCommunicator.SendAsync(adminEmail);

            ViewBag.Message = "Thank you for message";
            return(View());
        }