using SendGrid; using SendGrid.Helpers.Mail; // Create a new message var message = new SendGridMessage(); // Add a recipient to the message message.AddTo(new EmailAddress("[email protected]")); // Send the message var client = new SendGridClient(apiKey); var response = await client.SendEmailAsync(message);
using SendGrid; using SendGrid.Helpers.Mail; // Create a new message var message = new SendGridMessage(); // Add multiple recipients to the message var recipients = new ListIn this example, multiple recipients are added to the message using the AddTos method. The recipients are specified as a list of EmailAddress objects, each containing an email address and a display name. The SendGridMessage class is part of the SendGrid package library.{ new EmailAddress("[email protected]", "John Smith"), new EmailAddress("[email protected]", "Jane Doe"), new EmailAddress("[email protected]", "Bob Johnson") }; message.AddTos(recipients); // Send the message var client = new SendGridClient(apiKey); var response = await client.SendEmailAsync(message);