这段代码有问题吗?我已经将我的电子邮件放入我的代码中,但我没有收到任何电子邮件。我有一个提示,它不起作用,因为我使用的是 API 密钥 ID 而不是 API 密钥,因为我看不到我的 API 密钥,因为它只显示一次。如果这就是这段代码不起作用的原因。有没有办法再次查看您的 API 密钥?
public string SendEmailMain()
{
SendEmail().Wait();
}
static async Task SendEmail()
{
common com = new common();
var apiKey = com.sendGridAPI;
var client = new SendGridClient(apiKey);
var from = new EmailAddress("testmail@gmail.com", "test user");
var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress("testemai@gmail.com", "teset user");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
}