我正在使用Sendgrid发送电子邮件。我可以发送给多个收件人。谁能建议我们是否可以将电子邮件从Sendgrid发送到c#中的通讯组列表。我尝试提供分发列表,但是没有电子邮件发送给该列表的成员
static async Task SendNotification(string emailContent, string status)
{
try
{
var client = new SendGridClient(SendGridAPIKey);
var msg = new SendGridMessage()
{
From = new EmailAddress(FromEmail),
Subject = _enVironment + " : " + Subject + " " + status + " : " + DateTime.UtcNow,
};
msg.AddContent("text/html", emailContent);
string[] strToEmail = ToEmail.Split(';');
foreach (string ToEmail in strToEmail)
{
msg.AddTo(new EmailAddress(ToEmail));
}
if (!string.IsNullOrEmpty(CcEmail))
{
msg.AddCc(new EmailAddress(CcEmail));
}
var response = await client.SendEmailAsync(msg);
}
catch (Exception e)
{
throw e;
}
}