Skip to content

Commit

Permalink
Merge pull request #164 from sendgrid/apikeys-2
Browse files Browse the repository at this point in the history
Implement pull #127, add api key constructors
  • Loading branch information
thinkingserious committed Nov 25, 2015
2 parents d685ac8 + 1c1806d commit 6d5b3a4
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 238 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Change Log
# Change Log
All notable changes to this project will be documented in this file.

## [6.3.0] - 2015-11-24
###Added
- Send emails using API Key

## [6.2.0] - 2015-11-18
###Added
- Added support for using the Web API v3 endpoints.
- Added support for using the Web API v3 endpoints
- Implemented the api_keys endpoint [GET, POST, PATCH, DELETE]

## [6.1.0] - 2015-4-27
###Added
- Added support for sending via API keys in addition to credentials. Pass an API Key string to the Web transport constructor.
- Added support for sending via API keys in addition to credentials. Pass an API Key string to the Web transport constructor

## [6.0.1] - 2015-4-24
###Fixed
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,8 @@ After creating an email message, you can send it using the Web API provided by S

Sending email requires that you supply your SendGrid account credentials (username and password) OR a SendGrid API Key. API Key is the preferred method. API Keys are in beta. To configure API keys, visit https://sendgrid.com/beta/settings/api_keys

Using Credentials
```csharp
// Create network credentials to access your SendGrid account.
var username = "your_sendgrid_username";
var pswd = "your_sendgrid_password";

var credentials = new NetworkCredential(username, pswd);
```
To send an email message, use the **DeliverAsync** method on the **Web** transport class, which calls the SendGrid Web API. The following example shows how to send a message.


```csharp
// Create the email object first, then add the properties.
SendGridMessage myMessage = new SendGridMessage();
Expand All @@ -80,18 +71,12 @@ myMessage.From = new MailAddress("[email protected]", "John Smith");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World!";

// Create credentials, specifying your user name and password.
var credentials = new NetworkCredential("username", "password");

// Create an Web transport for sending email, using credentials...
//var transportWeb = new Web(credentials);
// ...OR create a Web transport, using API Key (preferred)
var transportWeb = new Web("This string is an API key");
// Create a Web transport, using API Key
var transportWeb = new Web("This string is a SendGrid API key");

// Send the email.
transportWeb.DeliverAsync(myMessage);
// If your developing a Console Application, use the following
// NOTE: If your developing a Console Application, use the following so that the API call has time to complete
// transportWeb.DeliverAsync(myMessage).Wait();
```

Expand Down
10 changes: 2 additions & 8 deletions SendGrid/Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ private static void Main()

private static void SendAsync(SendGrid.SendGridMessage message)
{
// Create credentials, specifying your user Name and password.
var username = Environment.GetEnvironmentVariable("SENDGRID_USERNAME");
var password = Environment.GetEnvironmentVariable("SENDGRID_PASSWORD");
//string apikey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
var credentials = new NetworkCredential(username, password);

string apikey = Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
// Create a Web transport for sending email.
var transportWeb = new SendGrid.Web(credentials);
//var transportWeb2 = new SendGrid.Web(apikey);
var transportWeb = new SendGrid.Web(apikey);

// Send the email.
try
Expand Down
8 changes: 4 additions & 4 deletions SendGrid/SendGrid/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SendGrid")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("A client library for SendGrid Web API v3 endpoints")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("SendGrid")]
[assembly: AssemblyProduct("SendGrid")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("6.3.0")]
[assembly: AssemblyFileVersion("6.3.0")]
4 changes: 2 additions & 2 deletions SendGrid/SendGridMail/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("6.0.0")]
[assembly: AssemblyFileVersion("6.0.0")]
[assembly: AssemblyVersion("6.3.0")]
[assembly: AssemblyFileVersion("6.3.0")]
Loading

0 comments on commit 6d5b3a4

Please sign in to comment.