【发布时间】:2017-10-29 22:08:10
【问题描述】:
我正在尝试使用带有 API 密钥的 SendGrid API 发送电子邮件。
问题是:我必须从旧的 .net 应用程序中执行此操作,其 asp.net 框架版本是 3.5(并且不能更改框架版本)
我找不到有关如何实现它的有用信息。我发现的唯一代码使用SendGrid csharp libraries,这些不支持asp.net framework 3.5
这是我找到 here 的代码示例,但我无法从我的 .net 3.5 网络应用程序中完成这项工作:
// 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();
有什么想法吗?
【问题讨论】:
标签: c# asp.net sendgrid sendgrid-api-v3 sendgrid-api-v2