diff --git a/.travis.yml b/.travis.yml
index ac74209f5..8f8874dd6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,9 +25,15 @@ script:
- dotnet restore
- dotnet build ./src/SendGrid -c Release
- dotnet test ./tests/SendGrid.Tests/SendGrid.Tests.csproj -c Release -f netcoreapp1.0
- - ls /home/travis/build/sendgrid/sendgrid-csharp/src/SendGrid/bin/Release/net452/
- - ls /home/travis/build/sendgrid/sendgrid-csharp/src/SendGrid/bin/Release/netstandard1.3/
+ - ls ./src/SendGrid/bin/Release/net452/
+ - ls ./src/SendGrid/bin/Release/netstandard1.3/
- dotnet pack ./src/SendGrid -c Release
+ - curl -s https://codecov.io/bash > .codecov
+ - chmod +x .codecov
+ - ./.codecov
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
notifications:
hipchat:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 22453042a..e3941a4a3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,6 +9,7 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou
- [Testing](#testing)
- [Style Guidelines & Naming Conventions](#style-guidelines-and-naming-conventions)
- [Creating a Pull Request](#creating-a-pull-request)
+- [Code Reviews](#code-reviews)
We use [GitHub Projects](https://github.com/sendgrid/sendgrid-csharp/projects) to help define current roadmaps, please feel free to grab an issue from our [GitHub Issues](https://github.com/sendgrid/sendgrid-csharp/issues). Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
@@ -75,7 +76,7 @@ git clone https://github.com/sendgrid/sendgrid-csharp.git
- Open `sendgrid-csharp/SendGrid.sln`
-## Environment Variables
+### Environment Variables
First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-csharp).
@@ -90,23 +91,23 @@ Next, update your Environment with your [SENDGRID_APIKEY](https://app.sendgrid.c
## Understanding the Code Base
-**/examples**
+**[/examples](https://github.com/sendgrid/sendgrid-csharp/blob/master/examples)**
Examples that demonstrate usage.
-**/ExampleCoreProject/Example.cs**
+**[/ExampleCoreProject/Example.cs](https://github.com/sendgrid/sendgrid-csharp/blob/master/ExampleCoreProject/Example.cs)**
A working .NET Core example project for testing.
-**/ExampleNet45Project/Example.cs**
+**[/ExampleNet45Project/Example.cs](https://github.com/sendgrid/sendgrid-csharp/blob/master/ExampleNet45Project/Example.cs)**
A working .NET 4.5.2 example project for testing.
-**src/SendGrid/SendGridClient.cs**
+**[/src/SendGrid/SendGridClient.cs](https://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/SendGridClient.cs)**
The main interface to the SendGrid API is the class `SendGridClient`.
-**/tests/SendGrid.Tests/Integration.cs**
+**[/tests/SendGrid.Tests/Integration.cs](https://github.com/sendgrid/sendgrid-csharp/blob/master/tests/SendGrid.Tests/Integration.cs)**
Integration tests
@@ -187,3 +188,8 @@ Generally, we follow the style guidelines as suggested by the official language.
with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
+
+
+## Code Reviews
+
+If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some great information on how to review a Pull Request.
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index f3cd0ef82..f7f4643ad 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2012-2017 SendGrid, Inc.
+Copyright (c) 2012-2018 SendGrid, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index b95d20707..9084b5e6a 100644
--- a/README.md
+++ b/README.md
@@ -245,6 +245,7 @@ Quick links:
- [Bug Reports](https://github.com/sendgrid/sendgrid-csharp/tree/master/CONTRIBUTING.md#submit-a-bug-report)
- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-csharp/tree/master/CONTRIBUTING.md#cla)
- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-csharp/tree/master/CONTRIBUTING.md#improvements-to-the-codebase)
+- [Review Pull Requests](https://github.com/sendgrid/sendgrid-csharp/tree/master/CONTRIBUTING.md#code-reviews)
# Troubleshooting
diff --git a/USAGE.md b/USAGE.md
index c0d35293f..84b5bf008 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -3135,7 +3135,7 @@ Console.ReadLine();
**This endpoint returns a list of all scopes that this user has access to.**
-API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
+API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissions, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
### GET /scopes
diff --git a/USE_CASES.md b/USE_CASES.md
index 4752d2d51..cf910100e 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -12,6 +12,7 @@ This documentation provides examples for specific use cases. Please [open an iss
* [Transient Fault Handling](#transient-faults)
* [How to Setup a Domain Whitelabel](#domain-whitelabel)
* [How to View Email Statistics](#email-stats)
+* [How to transform HTML to plain text](#html-to-plain-text)
# Attachments
@@ -845,3 +846,33 @@ Find more information about all of SendGrid's whitelabeling related documentatio
You can find documentation for how to view your email statistics via the UI [here](https://app.sendgrid.com/statistics) and via API [here](https://github.com/sendgrid/sendgrid-csharp/blob/master/USAGE.md#stats).
Alternatively, we can post events to a URL of your choice via our [Event Webhook](https://sendgrid.com/docs/API_Reference/Webhooks/event.html) about events that occur as SendGrid processes your email.
+
+
+# How to transform HTML to plain text
+
+Although the HTML tags could be removed using regular expressions, the best solution is parsing the HTML code with a specific library, such as [HTMLAgilityPack](http://html-agility-pack.net/).
+
+The following code shows how to parse an input string with HTML code and remove all tags:
+
+```csharp
+using HtmlAgilityPack;
+
+namespace Example {
+
+ internal class Example
+ {
+ ///
+ /// Convert the HTML content to plain text
+ ///
+ /// The html content which is going to be converted
+ /// A string
+ public static string HtmlToPlainText(string html)
+ {
+ HtmlDocument document = new HtmlDocument();
+ document.LoadHtml(html);
+ return document.DocumentNode == null ? string.Empty : document.DocumentNode.InnerText;
+ }
+ }
+}
+
+```
\ No newline at end of file
diff --git a/nuspec/Sendgrid.9.9.0.nuspec b/nuspec/Sendgrid.9.9.0.nuspec
index 8dd2f9359..02ef4ad27 100644
--- a/nuspec/Sendgrid.9.9.0.nuspec
+++ b/nuspec/Sendgrid.9.9.0.nuspec
@@ -19,16 +19,26 @@
SendGrid, Inc. 2017SendGrid Email Mail Microsoft Azure Transactional .NET Core
-
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/src/SendGrid/Helpers/Mail/MailHelper.cs b/src/SendGrid/Helpers/Mail/MailHelper.cs
index 0e525cce6..91a0ed909 100644
--- a/src/SendGrid/Helpers/Mail/MailHelper.cs
+++ b/src/SendGrid/Helpers/Mail/MailHelper.cs
@@ -1,302 +1,301 @@
-//
-// Copyright (c) SendGrid. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-namespace SendGrid.Helpers.Mail
+//
+// Copyright (c) SendGrid. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+
+namespace SendGrid.Helpers.Mail
{
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
-
- ///
- /// Simplified email sending for common use cases
- ///
- public class MailHelper
- {
- private const string NameGroup = "name";
- private const string EmailGroup = "email";
- private static readonly Regex Rfc2822Regex = new Regex(
- $@"(?:(?<{NameGroup}>)(?<{EmailGroup}>[^\<]*@.*[^\>])|(?<{NameGroup}>[^\<]*)\<(?<{EmailGroup}>.*@.*)\>)",
- RegexOptions.ECMAScript);
-
- ///
- /// Send a single simple email
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// An email object that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The subject of your email. This may be overridden by SetGlobalSubject().
- /// The text/plain content of the email body.
- /// The text/html content of the email body.
- /// A SendGridMessage object.
- public static SendGridMessage CreateSingleEmail(
- EmailAddress from,
- EmailAddress to,
- string subject,
- string plainTextContent,
- string htmlContent)
- {
- var msg = new SendGridMessage();
- msg.SetFrom(from);
- msg.SetSubject(subject);
- if (!string.IsNullOrEmpty(plainTextContent))
- {
- msg.AddContent(MimeType.Text, plainTextContent);
- }
-
- if (!string.IsNullOrEmpty(htmlContent))
- {
- msg.AddContent(MimeType.Html, htmlContent);
- }
-
- msg.AddTo(to);
- return msg;
- }
-
- ///
- /// Send a single dynamic template email
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// An email object that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The ID of the template.
- /// The data with which to populate the dynamic template.
- /// A SendGridMessage object.
- public static SendGridMessage CreateSingleDynamicTemplateEmail(
- EmailAddress from,
- EmailAddress to,
- string templateId,
- object dynamicTemplateData)
+ ///
+ /// Simplified email sending for common use cases
+ ///
+ public class MailHelper
+ {
+ private const string NameGroup = "name";
+ private const string EmailGroup = "email";
+ private static readonly Regex Rfc2822Regex = new Regex(
+ $@"(?:(?<{NameGroup}>)(?<{EmailGroup}>[^\<]*@.*[^\>])|(?<{NameGroup}>[^\<]*)\<(?<{EmailGroup}>.*@.*)\>)",
+ RegexOptions.ECMAScript);
+
+ ///
+ /// Send a single simple email
+ ///
+ /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
+ /// An email object that may contain the recipient’s name, but must always contain the recipient’s email.
+ /// The subject of your email. This may be overridden by SetGlobalSubject().
+ /// The text/plain content of the email body.
+ /// The text/html content of the email body.
+ /// A SendGridMessage object.
+ public static SendGridMessage CreateSingleEmail(
+ EmailAddress from,
+ EmailAddress to,
+ string subject,
+ string plainTextContent,
+ string htmlContent)
+ {
+ var msg = new SendGridMessage();
+ msg.SetFrom(from);
+ msg.SetSubject(subject);
+ if (!string.IsNullOrEmpty(plainTextContent))
+ {
+ msg.AddContent(MimeType.Text, plainTextContent);
+ }
+
+ if (!string.IsNullOrEmpty(htmlContent))
+ {
+ msg.AddContent(MimeType.Html, htmlContent);
+ }
+
+ msg.AddTo(to);
+ return msg;
+ }
+
+ ///
+ /// Send a single dynamic template email
+ ///
+ /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
+ /// An email object that may contain the recipient’s name, but must always contain the recipient’s email.
+ /// The ID of the template.
+ /// The data with which to populate the dynamic template.
+ /// A SendGridMessage object.
+ public static SendGridMessage CreateSingleDynamicTemplateEmail(
+ EmailAddress from,
+ EmailAddress to,
+ string templateId,
+ object dynamicTemplateData)
{
if (string.IsNullOrWhiteSpace(templateId))
{
throw new ArgumentException($"{nameof(templateId)} is required when creating a dynamic template email.", nameof(templateId));
}
- var msg = new SendGridMessage();
- msg.SetFrom(from);
- msg.AddTo(to);
- msg.TemplateId = templateId;
-
+ var msg = new SendGridMessage();
+ msg.SetFrom(from);
+ msg.AddTo(to);
+ msg.TemplateId = templateId;
+
if (dynamicTemplateData != null)
{
msg.SetDynamicTemplateData(dynamicTemplateData);
- }
-
- return msg;
- }
-
- ///
- /// Send a single simple email to multiple recipients
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The subject of your email. This may be overridden by SetGlobalSubject().
- /// The text/plain content of the email body.
- /// The text/html content of the email body.
- /// A SendGridMessage object.
- public static SendGridMessage CreateSingleEmailToMultipleRecipients(
- EmailAddress from,
- List tos,
- string subject,
- string plainTextContent,
- string htmlContent)
- {
- var msg = new SendGridMessage();
- msg.SetFrom(from);
- msg.SetGlobalSubject(subject);
- if (!string.IsNullOrEmpty(plainTextContent))
- {
- msg.AddContent(MimeType.Text, plainTextContent);
- }
-
- if (!string.IsNullOrEmpty(htmlContent))
- {
- msg.AddContent(MimeType.Html, htmlContent);
- }
-
- for (var i = 0; i < tos.Count; i++)
- {
- msg.AddTo(tos[i], i);
- }
-
- return msg;
- }
-
- ///
- /// Send a single simple email to multiple recipients
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The ID of the template.
- /// The data with which to populate the dynamic template.
- /// A SendGridMessage object.
- public static SendGridMessage CreateSingleDynamicTemplateEmailToMultipleRecipients(
- EmailAddress from,
- List tos,
- string templateId,
- object dynamicTemplateData)
- {
+ }
+
+ return msg;
+ }
+
+ ///
+ /// Send a single simple email to multiple recipients
+ ///
+ /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
+ /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
+ /// The subject of your email. This may be overridden by SetGlobalSubject().
+ /// The text/plain content of the email body.
+ /// The text/html content of the email body.
+ /// A SendGridMessage object.
+ public static SendGridMessage CreateSingleEmailToMultipleRecipients(
+ EmailAddress from,
+ List tos,
+ string subject,
+ string plainTextContent,
+ string htmlContent)
+ {
+ var msg = new SendGridMessage();
+ msg.SetFrom(from);
+ msg.SetGlobalSubject(subject);
+ if (!string.IsNullOrEmpty(plainTextContent))
+ {
+ msg.AddContent(MimeType.Text, plainTextContent);
+ }
+
+ if (!string.IsNullOrEmpty(htmlContent))
+ {
+ msg.AddContent(MimeType.Html, htmlContent);
+ }
+
+ for (var i = 0; i < tos.Count; i++)
+ {
+ msg.AddTo(tos[i], i);
+ }
+
+ return msg;
+ }
+
+ ///
+ /// Send a single simple email to multiple recipients
+ ///
+ /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
+ /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
+ /// The ID of the template.
+ /// The data with which to populate the dynamic template.
+ /// A SendGridMessage object.
+ public static SendGridMessage CreateSingleDynamicTemplateEmailToMultipleRecipients(
+ EmailAddress from,
+ List tos,
+ string templateId,
+ object dynamicTemplateData)
+ {
if (string.IsNullOrWhiteSpace(templateId))
{
throw new ArgumentException($"{nameof(templateId)} is required when creating a dynamic template email.", nameof(templateId));
}
- var msg = new SendGridMessage();
+ var msg = new SendGridMessage();
msg.SetFrom(from);
- msg.TemplateId = templateId;
+ msg.TemplateId = templateId;
var setDynamicTemplateDataValues = dynamicTemplateData != null;
- for (var i = 0; i < tos.Count; i++)
- {
- msg.AddTo(tos[i], i);
-
+ for (var i = 0; i < tos.Count; i++)
+ {
+ msg.AddTo(tos[i], i);
+
if (setDynamicTemplateDataValues)
{
msg.SetDynamicTemplateData(dynamicTemplateData, i);
- }
- }
-
- return msg;
- }
-
- ///
- /// Send multiple emails to multiple recipients.
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The subject of your email. This may be overridden by SetGlobalSubject().
- /// The text/plain content of the email body.
- /// The text/html content of the email body.
- /// Substitution key/values to customize the content for each email.
- /// A SendGridMessage object.
- public static SendGridMessage CreateMultipleEmailsToMultipleRecipients(
- EmailAddress from,
- List tos,
- List subjects,
- string plainTextContent,
- string htmlContent,
- List> substitutions)
- {
- var msg = new SendGridMessage();
- msg.SetFrom(from);
- if (!string.IsNullOrEmpty(plainTextContent))
- {
- msg.AddContent(MimeType.Text, plainTextContent);
- }
-
- if (!string.IsNullOrEmpty(htmlContent))
- {
- msg.AddContent(MimeType.Html, htmlContent);
- }
-
- for (var i = 0; i < tos.Count; i++)
- {
- msg.AddTo(tos[i], i);
- msg.SetSubject(subjects[i], i);
- msg.AddSubstitutions(substitutions[i], i);
- }
-
- return msg;
- }
-
- ///
- /// Send multiple emails to multiple recipients.
- ///
- /// An email object that may contain the recipient’s name, but must always contain the sender’s email.
- /// A list of email objects that may contain the recipient’s name, but must always contain the recipient’s email.
- /// The ID of the template.
- /// The data with which to populate the dynamic template.
- /// A SendGridMessage object.
- public static SendGridMessage CreateMultipleDynamicTemplateEmailsToMultipleRecipients(
- EmailAddress from,
- List tos,
- string templateId,
- List