public IActionResult sendEmail([FromBody] SendMessageResource messageResource) { bool result = emailService.sendEmail(messageResource); if (result) { return(Ok()); } else { return(BadRequest()); } }
public bool sendEmail(SendMessageResource messageResource) { SmtpClient client = configureClient(); MailMessage mail = new MailMessage("*****@*****.**", messageResource.Receivers[0]); messageResource.Receivers.ToList().ForEach(rec => mail.To.Add(rec)); mail.Subject = messageResource.Subject; mail.Body = messageResource.Message; try { client.SendAsync(mail, null); return(true); } catch (ObjectDisposedException) { return(false); } }