C# .net core的SendGrid API不发送电子邮件

C# .net core的SendGrid API不发送电子邮件,c#,visual-studio,email,.net-core,sendgrid,C#,Visual Studio,Email,.net Core,Sendgrid,我正试图按照以下指南实现sendgrid的.NET核心API: 但我不能发送任何电子邮件 public Task SendEmailAsync(string email, string subject, string message) { return Execute(Options.SendGridKey, subject, message, email); } public Task Execute(string apiKey, strin

我正试图按照以下指南实现sendgrid的.NET核心API:

但我不能发送任何电子邮件

    public Task SendEmailAsync(string email, string subject, string message)
    {
        return Execute(Options.SendGridKey, subject, message, email);
    }

    public Task Execute(string apiKey, string subject, string message, string email)
    {
        var client = new SendGridClient(apiKey);
        var msg = new SendGridMessage()
        {
            From = new EmailAddress("myemail@email.it", Options.SendGridUser),
            Subject = subject,
            PlainTextContent = message,
            HtmlContent = message
        };
        msg.AddTo(new EmailAddress(email));

        // Disable click tracking.
        // See https://sendgrid.com/docs/User_Guide/Settings/tracking.html
        msg.SetClickTracking(false, false);
        return client.SendEmailAsync(msg);
    }
代码不会出错,但不会发送电子邮件。 你有什么建议吗?
谢谢

我觉得很好。我将验证您的API密钥是否正确。您能否共享实际调用此方法的代码?出于安全原因,显然排除API。

如果您使用免费SendGrid计划,请注意某些电子邮件提供商可能会阻止来自Azure IP的发送这些电子邮件的请求。感谢您的回答,是的,我使用的是免费计划,outlook和gmail是否也会出现问题?因为我尝试了office365邮箱和gmail。感谢您的回复,我正在使用Identity Controrrel注册表,我无法完全同意代码,因为我超过了注释的长度。
public async Task OnPostAsync(string returnUrl=null){if(ModelState.IsValid){{wait{u emailSender.sendmailasync(Input.Email,“Conferma la tua Email”,$“Conferma il tuo account