使用 C# 的 SendGrid V3 api。电子邮件未发送

SendGrid V3 api with C#. email not sending

这段代码有问题吗?我已经把我的电子邮件放在我的代码中,但我没有收到任何电子邮件。 我有一个提示,它不起作用,因为我使用 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);

        }

代码运行良好。问题是我使用的是 API 密钥 ID,因为它不是由 sendgrid 生成的 API 密钥。

Please refer to this thread for more info