This library allows you to quickly and easily use the SendGrid Web API via C Sharp with .NET.
BREAKING CHANGE as of 2016.06.14
Version 7.0.0
is a breaking change for the entire library.
Version 7.0.0 brings you full support for all Web API v3 endpoints. We have the following resources to get you started quickly:
Thank you for your continued support!
All updates to this library is documented in our CHANGELOG.
First, get your free SendGrid account here.
Next, update your Environment (user space) with your SENDGRID_API_KEY.
To use SendGrid in your C# project, you can either download the SendGrid C# .NET libraries directly from our Github repository or, if you have the NuGet package manager installed, you can grab them automatically.
PM> Install-Package SendGrid
Once you have the SendGrid libraries properly referenced in your project, you can include calls to them in your code. For a sample implementation, check the Example folder.
Add the following namespaces to use the library:
using System;
using System.Web.Script.Serialization;
using SendGrid;
using SendGrid.Helpers.Mail; // Include if you want to use the Mail Helper
- The SendGrid Service, starting at the free level)
- SendGrid.CSharp.HTTP.Client
using System;
using SendGrid;
using SendGrid.Helpers.Mail;
namespace Example
{
internal class Example
{
private static void Main()
{
String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
dynamic sg = new SendGridAPIClient(apiKey);
Email from = new Email("[email protected]");
String subject = "Hello World from the SendGrid CSharp Library";
Email to = new Email("[email protected]");
Content content = new Content("text/plain", "Textual content");
Mail mail = new Mail(from, subject, to, content);
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
}
}
}
using System;
namespace Example
{
internal class Example
{
private static void Main()
{
String apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", EnvironmentVariableTarget.User);
dynamic sg = new SendGrid.SendGridAPIClient(apiKey);
dynamic response = sg.client.api_keys.get();
}
}
}
If you are intersted in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.
We encourage contribution to our library, please see our CONTRIBUTING guide for details.
Quick links:
sendgrid-csharp is guided and supported by the SendGrid Developer Experience Team.
sendgrid-csharp is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-csharp are trademarks of SendGrid, Inc.
![SendGrid Logo] (https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)