1

I am trying to send the same automatic email to multiple email addresses but I can't get it to work.

[HttpGet("largeorderemail")]
        public IActionResult LargeOrderEmail()
        {
            try
            {
                //var bodyString = $"<h3>{msg}</h3><br/><p> Visit the site <a href='{Startup.appSettings.AllowOrigin}/lidarweb'> LiDAR GIS portal.</a></p>";
                var bodyString = $"<h3>email body</h3>" +
                                  <br/>" +
                var emailService = new Email { To = "info@tel.net" };
                var response = emailService.ExecuteLargeOrder(bodyString);
                return Ok();
            }
            catch (Exception e)
            {
                Log.Error(e);
                return NotFound();
            }
        }

public async Task<Response> ExecuteLargeOrder(string bodyString)
        {
            var fromAddr = new EmailAddress(from, "Info");
            subject = "large order";
            var toAddr = new EmailAddress(to, "User");
            plainTextContent = "";
            htmlContent = bodyString;
            var msg = MailHelper.CreateSingleEmail(fromAddr, toAddr, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg);
            return response;
        }

When I send an email to a single address, it works. Like so: var emailService = new Email { To = "info@tel.net" }; but when I try something like this, it doesn't send the email var emailService = new Email { To = "info@tel.net, info@gmail.com" }; I also tried separating the address like so var emailService = new Email { To = "info@tel.net; info@gmail.com" }; but this also doesn't work.

Any suggestions?

Cucko
  • 175
  • 1
  • 16
  • Does this answer your question? [sendgrid multiple recipients c#](https://stackoverflow.com/questions/38725978/sendgrid-multiple-recipients-c-sharp) – devNull Sep 10 '21 at 23:44

1 Answers1

0

Instead of putting Email addresses, try doing this way. Keep all your Email address in Array and try looping through the Array so that you can achieve your goal.