发送网格 c# V3 api:无法从 MVC c# web 应用程序发送邮件:响应:错误请求:使用“RestClient” 问题摘要重现步骤代码片段异常/日志技术细节:注意:

问题描述

问题摘要

@H_404_2@响应:错误请求

@H_404_2@无法从 MVC c# web 应用程序发送邮件: 得到以下错误 响应:错误请求:使用“SendEmailAsync”响应:Id = 8,状态 = WaitingForActivation,方法 =“{null}”,结果 =“{尚未计算}”使用“RestClient”

重现步骤

  1. 在没有静态类的任何 MVC 应用程序中使用上述代码
  2. 运行代码
  3. 会抛出同样的错误

代码片段

//RestClient -- var client = new RestClient("https://api.sendgrid.com/v3/mail/send");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("Authorization","Bearer Sendgridtoken");
                request.AddHeader("Content-Type","application/json");
                request.AddParameter("application/json","{\"personalizations\":[{\"to\":[{\"email\":\"[email protected]\"}]}],\"from\":{\"email\":\"[email protected]\"},\"subject\":\"testing login\",\"content\":[{\"type\":\"text/plain\",\"value\":\"tesing login login\"}]}",ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                Console.WriteLine(response.Content);

异常/日志

@H_404_2@使用“SendEmailAsync”响应:Id = 8,状态 = WaitingForActivation,方法 =“{null}”,结果 =“{尚未计算}”使用“RestClient”响应:错误请求 ``

技术细节:

  • sendgrid-csharp 版本:SendGrid 9.22.0
  • csharp 版本:4.5

注意:

@H_404_2@我们没有为此实现使用任何静态方法 我们不是将其用作后台工作,而是将其作为一种方法来实现。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)