我有一个简单的 HTML 代码可以使用 C# API Sendgrid 和 Templates 发送到某个电子邮件:
但是当电子邮件被传递时,它无法识别“样式”或任何 css 代码..
这是我的代码:
static async Task Execute()
{
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
var client = new SendGridClient(apiKey);
var msg = new SendGridMessage();
msg.SetFrom(new EmailAddress("test@example.com", "Example User"));
msg.SetSubject("I'm replacing the subject tag");
msg.AddTo(new EmailAddress("myEmail", "Nathiel"));
//msg.AddContent(MimeType.Text, "I'm replacing the <strong>body tag</strong>");
msg.SetTemplateId("MyTemplateId");
msg.AddSubstitution("-cepFrom-", "54315-310");
var response = await client.SendEmailAsync(msg);
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.Headers.ToString());
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadLine();
}
我不知道怎么了!