无法使用webapi在Sendgrid上发送安全电子邮件

use*_*155 5 .net security sendmail sendgrid

我无法使用web api在Sendgrid上发送"安全"电子邮件.(平台 - .Net/C#,SendgridMail)

它适用于http url(http://sendgrid.com/api/mail.send),但使用https(https://sendgrid.com/api/mail.send)则失败.

   private void SendMail()
    {
        var message = SendGrid.GenerateInstance();

        //set the message recipients
        message.AddTo("to@sonedomain.com1");

        //set the sender
        message.From = new MailAddress("from@somedomain.com1");

        //set the message body
        message.Html = "<html><p>Hello</p><p>World</p></html>";

        //set the message subject
        message.Subject = "Hello World HTML Test";

        //create an instance of the Web transport mechanism
        var transportInstance = SendGridMail.Transport.REST.GetInstance(new NetworkCredential("myusername", "mypassword"),"https://sendgrid.com/api/mail.send");

        //send the mail
        transportInstance.Deliver(message);
    }
Run Code Online (Sandbox Code Playgroud)

我得到一个ArgumentException:未知元素:html.

进一步向下钻取代码,我收到此错误:"400 Bad Request,普通HTTP请求被发送到HTTPS端口,nginx/0.7.65"

注意
它适用于上面的GetInstance函数中的http url ie:(http://sendgrid.com/api/mail.send)而不是(https://sendgrid.com/api/mail.send).

通过浏览器发送电子邮件请求工作正常:(https://sendgrid.com/api/mail.send.json?to=to%40somedomain.com1&from=from%40somdomain.com1&subject=Test%20SG%20API&text=sometext&html=%3Cb% 3E%20test%20SG%20api%20body&api_user = sendgridusername&API_KEY = sendgridpassword)

对此的帮助表示赞赏.

bwe*_*est 4

我在 SendGrid 工作。我已经做了一些测试,这是 C# 包装器的限制,特别是用于进行 HTTP 调用的 CodeScales 库。不幸的是,CodeScales 根本不支持 HTTPS。我为此在 GitHub 上提出了一个问题:https ://github.com/sendgrid/sendgrid-csharp/issues/21

我将开始计划重构应用程序以使用 RestSharp 进行 API 调用。抱歉,添麻烦了!