summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail
diff options
context:
space:
mode:
authorBrandon West <brawest@gmail.com>2014-05-21 17:23:35 -0600
committerBrandon West <brawest@gmail.com>2014-05-21 17:23:35 -0600
commite497caefcf35acf753d35f41c209fa09f6d40e99 (patch)
treeb787e0c3007922cb1291a52b2efc1d6922d8813e /SendGrid/SendGridMail
parentc48471c02bc8e9d47e4735fda5e3244636b118ef (diff)
downloadsendgrid-csharp-e497caefcf35acf753d35f41c209fa09f6d40e99.zip
sendgrid-csharp-e497caefcf35acf753d35f41c209fa09f6d40e99.tar.gz
sendgrid-csharp-e497caefcf35acf753d35f41c209fa09f6d40e99.tar.bz2
change namespace from SendGridMail to SendGrid, change SendGrid type to SendGridMessage, update to depend on SendGrid.SmtpApi, remove CC and BCC methods since they are not supported in the web API currently.
Diffstat (limited to 'SendGrid/SendGridMail')
-rw-r--r--SendGrid/SendGridMail/ISendGrid.cs58
-rw-r--r--SendGrid/SendGridMail/Mail.csproj7
-rw-r--r--SendGrid/SendGridMail/Properties/AssemblyInfo.cs4
-rw-r--r--SendGrid/SendGridMail/SendGrid.cs62
-rw-r--r--SendGrid/SendGridMail/Transport/ITransport.cs2
-rw-r--r--SendGrid/SendGridMail/Transport/Web.cs10
-rw-r--r--SendGrid/SendGridMail/packages.config19
7 files changed, 39 insertions, 123 deletions
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs
index 534e644..b487741 100644
--- a/SendGrid/SendGridMail/ISendGrid.cs
+++ b/SendGrid/SendGridMail/ISendGrid.cs
@@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
-using Smtpapi;
+using SendGrid.SmtpApi;
-namespace SendGridMail
+namespace SendGrid
{
/// <summary>
/// Represents the basic set of functions that will be called by the user
@@ -64,50 +64,6 @@ namespace SendGridMail
void AddTo(IDictionary<String, IDictionary<String, String>> addresssInfo);
/// <summary>
- /// Add to the 'CC' address.
- /// </summary>
- /// <param name="address">a single email address eg "you@company.com"</param>
- void AddCc(String address);
-
- /// <summary>
- /// Add to the 'CC' address.
- /// </summary>
- /// <param name="addresses">a list of email addresses as strings</param>
- void AddCc(IEnumerable<String> addresses);
-
- /// <summary>
- /// Add to the 'CC' address.
- /// </summary>
- /// <param name="addresssInfo">
- /// the dictionary keys are the email addresses, which points to a dictionary of
- /// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' }
- /// }
- /// </param>
- void AddCc(IDictionary<String, IDictionary<String, String>> addresssInfo);
-
- /// <summary>
- /// Add to the 'Bcc' address.
- /// </summary>
- /// <param name="address">a single email as the input eg "you@company.com"</param>
- void AddBcc(String address);
-
- /// <summary>
- /// Add to the 'Bcc' address.
- /// </summary>
- /// <param name="addresses">a list of emails as an array of strings.</param>
- void AddBcc(IEnumerable<String> addresses);
-
- /// <summary>
- /// Add to the 'Bcc' address.
- /// </summary>
- /// <param name="addresssInfo">
- /// the dictionary keys are the email addresses, which points to a dictionary of
- /// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' }
- /// }
- /// </param>
- void AddBcc(IDictionary<String, IDictionary<String, String>> addresssInfo);
-
- /// <summary>
/// Defines a mapping between a replacement string in the text of the message to a list of
/// substitution values to be used, one per each recipient, in the same order as the recipients were added.
/// </summary>
@@ -119,7 +75,7 @@ namespace SendGridMail
void AddSubstitution(String replacementTag, List<String> substitutionValues);
/// <summary>
- /// This adds parameters and values that will be bassed back through SendGrid's
+ /// This adds parameters and values that will be bassed back through SendGridMessage's
/// Event API if an event notification is triggered by this email.
/// </summary>
/// <param name="identifiers">parameter substitutionValues pairs to be passed back on event notification</param>
@@ -235,7 +191,7 @@ namespace SendGridMail
void EnableOpenTracking();
/// <summary>
- /// Causes all links to be overwritten, shortened, and pointed to SendGrid's servers so clicks will be tracked.
+ /// Causes all links to be overwritten, shortened, and pointed to SendGridMessage's servers so clicks will be tracked.
/// </summary>
/// <param name="includePlainText">true if links found in plain text portions of the message are to be overwritten</param>
void EnableClickTracking(bool includePlainText = false);
@@ -247,18 +203,18 @@ namespace SendGridMail
/// Emails with a SpamAssassin score over this substitutionValues will be considered spam and not be
/// delivered.
/// </param>
- /// <param name="url">SendGrid will send an HTTP POST request to this url when a message is detected as spam</param>
+ /// <param name="url">SendGridMessage will send an HTTP POST request to this url when a message is detected as spam</param>
void EnableSpamCheck(int score = 5, String url = null);
/// <summary>
- /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
+ /// Allow's SendGridMessage to manage unsubscribes and ensure these users don't get future emails from the sender
/// </summary>
/// <param name="text">String for the plain text email body showing what you want the message to look like.</param>
/// <param name="html">String for the HTML email body showing what you want the message to look like.</param>
void EnableUnsubscribe(String text, String html);
/// <summary>
- /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
+ /// Allow's SendGridMessage to manage unsubscribes and ensure these users don't get future emails from the sender
/// </summary>
/// <param name="replace">Tag in the message body to be replaced with the unsubscribe link and message</param>
void EnableUnsubscribe(String replace);
diff --git a/SendGrid/SendGridMail/Mail.csproj b/SendGrid/SendGridMail/Mail.csproj
index 9d3c35f..89a926c 100644
--- a/SendGrid/SendGridMail/Mail.csproj
+++ b/SendGrid/SendGridMail/Mail.csproj
@@ -8,7 +8,7 @@
<ProjectGuid>{3C687BEF-FF50-44AD-8315-2D4237281AF8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>SendGridMail</RootNamespace>
+ <RootNamespace>SendGrid</RootNamespace>
<AssemblyName>SendGridMail</AssemblyName>
<FileAlignment>512</FileAlignment>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
@@ -45,8 +45,8 @@
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.16\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
- <Reference Include="Smtpapi">
- <HintPath>..\packages\smtpapi.1.0.0\lib\Smtpapi.dll</HintPath>
+ <Reference Include="SendGrid.SmtpApi">
+ <HintPath>..\packages\SendGrid.SmtpApi.1.1.3\lib\net40\SendGrid.SmtpApi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -76,6 +76,7 @@
<Compile Include="Transport\Web.cs" />
</ItemGroup>
<ItemGroup>
+ <None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
index f47a2ad..14f014d 100644
--- a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
+++ b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs
@@ -7,9 +7,9 @@ using System.Runtime.InteropServices;
// associated with an assembly.
[assembly: AssemblyTitle("SendGridMail")]
-[assembly: AssemblyDescription("A client library for interfacing with the SendGrid API")]
+[assembly: AssemblyDescription("A client library for interfacing with the SendGridMessage API")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("SendGrid")]
+[assembly: AssemblyCompany("SendGridMessage")]
[assembly: AssemblyProduct("SendGridMail")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 3d2c6e2..09aa1fe 100644
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -6,11 +6,11 @@ using System.Linq;
using System.Net.Mail;
using System.Net.Mime;
using System.Text.RegularExpressions;
-using Smtpapi;
+using SendGrid.SmtpApi;
-namespace SendGridMail
+namespace SendGrid
{
- public class SendGrid : ISendGrid
+ public class SendGridMessage : ISendGrid
{
#region constants/vars
@@ -25,22 +25,22 @@ namespace SendGridMail
#region Initialization and Constructors
/// <summary>
- /// Creates an instance of SendGrid's custom message object
+ /// Creates an instance of SendGridMessage's custom message object
/// </summary>
/// <returns></returns>
- public SendGrid() : this(new Header())
+ public SendGridMessage() : this(new Header())
{
}
- public SendGrid(IHeader header)
+ public SendGridMessage(IHeader header)
{
_message = new MailMessage();
Header = header;
Headers = new Dictionary<string, string>();
}
- public SendGrid(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
+ public SendGridMessage(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
String subject, String html, String text, IHeader header = null) : this(header)
{
From = from;
@@ -175,53 +175,7 @@ namespace SendGridMail
}
}
- public void AddCc(String address)
- {
- var mailAddress = new MailAddress(address);
- _message.CC.Add(mailAddress);
- }
-
- public void AddCc(IEnumerable<String> addresses)
- {
- if (addresses == null) return;
- foreach (var address in addresses.Where(address => address != null))
- {
- AddCc(address);
- }
- }
-
- public void AddCc(IDictionary<String, IDictionary<String, String>> addresssInfo)
- {
- foreach (var mailAddress in from address in addresssInfo.Keys let table = addresssInfo[address] select new MailAddress(address, table.ContainsKey("DisplayName") ? table["DisplayName"] : null))
- {
- _message.CC.Add(mailAddress);
- }
- }
-
- public void AddBcc(String address)
- {
- var mailAddress = new MailAddress(address);
- _message.Bcc.Add(mailAddress);
- }
-
- public void AddBcc(IEnumerable<String> addresses)
- {
- if (addresses == null) return;
- foreach (var address in addresses.Where(address => address != null))
- {
- AddBcc(address);
- }
- }
-
- public void AddBcc(IDictionary<String, IDictionary<String, String>> addresssInfo)
- {
- foreach (var mailAddress in from address in addresssInfo.Keys let table = addresssInfo[address] select new MailAddress(address, table.ContainsKey("DisplayName") ? table["DisplayName"] : null))
- {
- _message.Bcc.Add(mailAddress);
- }
- }
-
- public Dictionary<String, MemoryStream> StreamedAttachments
+ public Dictionary<String, MemoryStream> StreamedAttachments
{
get { return _streamedAttachments; }
set { _streamedAttachments = value; }
diff --git a/SendGrid/SendGridMail/Transport/ITransport.cs b/SendGrid/SendGridMail/Transport/ITransport.cs
index 99b620c..8de134c 100644
--- a/SendGrid/SendGridMail/Transport/ITransport.cs
+++ b/SendGrid/SendGridMail/Transport/ITransport.cs
@@ -1,4 +1,4 @@
-namespace SendGridMail
+namespace SendGrid
{
/// <summary>
/// Encapsulates the transport mechanism so that it can be used in a generic way,
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs
index 7bb8e58..615ac00 100644
--- a/SendGrid/SendGridMail/Transport/Web.cs
+++ b/SendGrid/SendGridMail/Transport/Web.cs
@@ -7,10 +7,10 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Xml;
-using Smtpapi;
+using SendGrid.SmtpApi;
// ReSharper disable MemberCanBePrivate.Global
-namespace SendGridMail
+namespace SendGrid
{
public class Web : ITransport
{
@@ -27,7 +27,7 @@ namespace SendGridMail
/// <summary>
/// Creates a new Web interface for sending mail. Preference is using the Factory method.
/// </summary>
- /// <param name="credentials">SendGrid user parameters</param>
+ /// <param name="credentials">SendGridMessage user parameters</param>
/// <param name="https">Use https?</param>
public Web(NetworkCredential credentials)
{
@@ -35,7 +35,7 @@ namespace SendGridMail
}
/// <summary>
- /// Delivers a message over SendGrid's Web interface
+ /// Delivers a message over SendGridMessage's Web interface
/// </summary>
/// <param name="message"></param>
public void Deliver(ISendGrid message)
@@ -53,7 +53,7 @@ namespace SendGridMail
}
/// <summary>
- /// Asynchronously delivers a message over SendGrid's Web interface
+ /// Asynchronously delivers a message over SendGridMessage's Web interface
/// </summary>
/// <param name="message"></param>
public async void DeliverAsync(ISendGrid message)
diff --git a/SendGrid/SendGridMail/packages.config b/SendGrid/SendGridMail/packages.config
index 0470bc3..8ff7b73 100644
--- a/SendGrid/SendGridMail/packages.config
+++ b/SendGrid/SendGridMail/packages.config
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Microsoft.Bcl" version="1.0.19" targetFramework="net40" />
- <package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net40" />
- <package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net40" />
- <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
- <package id="smtpapi" version="1.0.0" targetFramework="net40" />
-</packages> \ No newline at end of file
+<dependencies>
+ <group targetFramework="net40">
+ <dependency id="Microsoft.Bcl" version="1.1.6" />
+ <dependency id="Microsoft.Bcl.Build" version="1.0.13" />
+ <dependency id="Microsoft.Net.Http" version="2.2.18" />
+ <dependency id="SendGrid.SmtpApi" version="1.1.3" />
+ </group>
+
+ <group targetFramework="net45">
+ <dependency id="SendGrid.SmtpApi" version="1.1.3" />
+ </group>
+</dependencies> \ No newline at end of file