예제 #1
0
        public IActionResult sendEmail([FromBody] SendMessageResource messageResource)
        {
            bool result = emailService.sendEmail(messageResource);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #2
0
        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);
            }
        }