Skip to content

Commit

Permalink
Update README with API Key instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed Nov 25, 2015
1 parent 5b355fb commit 71b2b38
Showing 1 changed file with 3 additions and 18 deletions.
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

0 comments on commit 71b2b38

Please sign in to comment.