C# 从ASP.Net Framework 3.5发送带有SendGrid API的电子邮件
我正在尝试使用SendGrid API发送一封电子邮件,其中包含我已经拥有的API密钥 问题是:我必须从一个旧的.net应用程序中执行此操作,它的asp.net framework版本是3.5(并且更改framework版本不是一个选项) 我没有找到关于如何实现这一目标的有用信息。我发现的唯一代码使用了,这些代码不支持asp.net framework 3.5 这是我找到的代码示例,但我无法从我的.net 3.5 web应用程序中执行此操作:C# 从ASP.Net Framework 3.5发送带有SendGrid API的电子邮件,c#,asp.net,sendgrid,sendgrid-api-v3,sendgrid-api-v2,C#,Asp.net,Sendgrid,Sendgrid Api V3,Sendgrid Api V2,我正在尝试使用SendGrid API发送一封电子邮件,其中包含我已经拥有的API密钥 问题是:我必须从一个旧的.net应用程序中执行此操作,它的asp.net framework版本是3.5(并且更改framework版本不是一个选项) 我没有找到关于如何实现这一目标的有用信息。我发现的唯一代码使用了,这些代码不支持asp.net framework 3.5 这是我找到的代码示例,但我无法从我的.net 3.5 web应用程序中执行此操作: // using SendGrid's C# Lib
// using SendGrid's C# Library - https://github.com/sendgrid/sendgrid-csharp
using System.Net.Http;
using System.Net.Mail;
var myMessage = new SendGrid.SendGridMessage();
myMessage.AddTo("test@sendgrid.com");
myMessage.From = new MailAddress("you@youremail.com", "First Last");
myMessage.Subject = "Sending with SendGrid is Fun";
myMessage.Text = "and easy to do anywhere, even with C#";
var transportWeb = new SendGrid.Web("SENDGRID_APIKEY");
transportWeb.DeliverAsync(myMessage);
// NOTE: If you're developing a Console Application, use the following so that the API call has time to complete
// transportWeb.DeliverAsync(myMessage).Wait();
有什么想法吗?你有几个选择。SendGrid API使用HttpClient类发出请求,这需要.NET 4+依赖项
ISendGridClient是一个有点奇怪的例子。它使用接口内部的实现来获取一些参数。看起来2和3是不错的选择 您有两个选择。SendGrid API使用HttpClient类发出请求,这需要.NET 4+依赖项