diff options
Diffstat (limited to 'SendGrid/SendGridMail')
-rwxr-xr-x | SendGrid/SendGridMail/ISendGrid.cs | 13 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Mail.csproj | 8 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Mail.nuspec | 15 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Properties/AssemblyInfo.cs | 1 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/SendGrid.cs | 23 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg | bin | 0 -> 34686 bytes | |||
-rwxr-xr-x | SendGrid/SendGridMail/Transport/ITransport.cs | 5 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Transport/REST.cs | 9 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/Transport/SMTP.cs | 4 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/lib/CodeScales.Http.dll | bin | 0 -> 40960 bytes |
10 files changed, 49 insertions, 29 deletions
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs index 3be707f..08d109c 100755 --- a/SendGrid/SendGridMail/ISendGrid.cs +++ b/SendGrid/SendGridMail/ISendGrid.cs @@ -1,11 +1,7 @@ using System;
using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Mail;
-using System.Net.Mime;
-using System.Text;
namespace SendGridMail
{
@@ -219,10 +215,13 @@ namespace SendGridMail /// </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
+ /// </summary>
/// <param name="replace">Tag in the message body to be replaced with the unsubscribe link and message</param>
- /// <param name="url">URL for a landing page, if you have your own prepared</param>
- /// <param name="landing">HTML body of a landing page created by SendGrid for you</param>
- void EnableUnsubscribe(String text, String html, String replace, String url, String landing);
+ void EnableUnsubscribe(String replace);
/// <summary>
/// Attaches a message at the footer of the email
diff --git a/SendGrid/SendGridMail/Mail.csproj b/SendGrid/SendGridMail/Mail.csproj index d652771..bd1dc7a 100755 --- a/SendGrid/SendGridMail/Mail.csproj +++ b/SendGrid/SendGridMail/Mail.csproj @@ -31,8 +31,9 @@ <WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="CodeScales.Http">
- <HintPath>..\packages\CodeScales.Http.dll</HintPath>
+ <Reference Include="CodeScales.Http, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>lib\CodeScales.Http.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -57,6 +58,9 @@ <Compile Include="Transport\SMTP.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="lib\CodeScales.Http.dll" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/SendGrid/SendGridMail/Mail.nuspec b/SendGrid/SendGridMail/Mail.nuspec new file mode 100755 index 0000000..39d44bf --- /dev/null +++ b/SendGrid/SendGridMail/Mail.nuspec @@ -0,0 +1,15 @@ +<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>Sendgrid</id>
+ <version>1.0.0</version>
+ <title>Sendgrid</title>
+ <authors>CJ Buchmann, Tyler Bischel, Eric Becking</authors>
+ <owners>Sendgrid</owners>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>$description$</description>
+ <releaseNotes>Basic C# client library and examples for using Sendgrid API's to send mail</releaseNotes>
+ <copyright>Copyright 2012</copyright>
+ <tags>Sendgrid Email Mail Microsoft Azure</tags>
+ </metadata>
+</package>
\ No newline at end of file diff --git a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs index 310fe3b..e6e890f 100755 --- a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs +++ b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs @@ -5,7 +5,6 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-
[assembly: AssemblyTitle("SendGridMail")]
[assembly: AssemblyDescription("A client library for interfacing with the SendGrid API")]
[assembly: AssemblyConfiguration("")]
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs index 4b91dfc..59d7976 100755 --- a/SendGrid/SendGridMail/SendGrid.cs +++ b/SendGrid/SendGridMail/SendGrid.cs @@ -30,7 +30,7 @@ namespace SendGridMail /// Creates an instance of SendGrid's custom message object
/// </summary>
/// <returns></returns>
- public static SendGrid GenerateInstance()
+ public static SendGrid GetInstance()
{
var header = new Header();
return new SendGrid(header);
@@ -48,7 +48,7 @@ namespace SendGridMail /// <param name="text">the plain text part of the message</param>
/// <param name="transport">Transport class to use for sending the message</param>
/// <returns></returns>
- public static SendGrid GenerateInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
+ public static SendGrid GetInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
String subject, String html, String text, TransportType transport)
{
var header = new Header();
@@ -394,7 +394,7 @@ namespace SendGridMail Header.AddFilterSetting(filter, new List<string> { "url" }, url);
}
- public void EnableUnsubscribe(string text, string html, string replace, string url, string landing)
+ public void EnableUnsubscribe(string text, string html)
{
var filter = _filters["Unsubscribe"];
@@ -410,10 +410,15 @@ namespace SendGridMail Header.Enable(filter);
Header.AddFilterSetting(filter, new List<string> { "text/plain" }, text);
- Header.AddFilterSetting(filter, new List<string> { "text/html" }, html);
- Header.AddFilterSetting(filter, new List<string> { "replace"}, replace);
- Header.AddFilterSetting(filter, new List<string> { "url"}, url);
- Header.AddFilterSetting(filter, new List<string> { "landing" }, landing);
+ Header.AddFilterSetting(filter, new List<string> {"text/html"}, html);
+ }
+
+ public void EnableUnsubscribe(string replace)
+ {
+ var filter = _filters["Unsubscribe"];
+
+ Header.Enable(filter);
+ Header.AddFilterSetting(filter, new List<string> { "replace" }, replace);
}
public void EnableFooter(string text = null, string html = null)
@@ -506,7 +511,7 @@ namespace SendGridMail /// Helper function lets us look at the mime before it is sent
/// </summary>
/// <param name="directory">directory in which we store this mime message</param>
- internal void SaveMessage(String directory)
+ public void SaveMessage(String directory)
{
var client = new SmtpClient("localhost")
{
@@ -523,7 +528,7 @@ namespace SendGridMail switch (Transport)
{
case TransportType.SMTP:
- transport = SMTP.GenerateInstance(credentials);
+ transport = SMTP.GetInstance(credentials);
break;
case TransportType.REST:
transport = REST.GetInstance(credentials);
diff --git a/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg b/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg Binary files differnew file mode 100755 index 0000000..aeaf84e --- /dev/null +++ b/SendGrid/SendGridMail/Sendgrid.1.0.0.nupkg diff --git a/SendGrid/SendGridMail/Transport/ITransport.cs b/SendGrid/SendGridMail/Transport/ITransport.cs index 26fccf4..b3a1936 100755 --- a/SendGrid/SendGridMail/Transport/ITransport.cs +++ b/SendGrid/SendGridMail/Transport/ITransport.cs @@ -1,7 +1,8 @@ namespace SendGridMail.Transport
{
/// <summary>
- ///
+ /// Encapsulates the transport mechanism so that it can be used in a generic way,
+ /// regardless of the transport type
/// </summary>
public interface ITransport
{
@@ -11,4 +12,4 @@ /// <param name="message">the message to be delivered</param>
void Deliver(ISendGrid message);
}
-}
+}
\ No newline at end of file diff --git a/SendGrid/SendGridMail/Transport/REST.cs b/SendGrid/SendGridMail/Transport/REST.cs index 7b8c361..614e024 100755 --- a/SendGrid/SendGridMail/Transport/REST.cs +++ b/SendGrid/SendGridMail/Transport/REST.cs @@ -1,6 +1,5 @@ using System;
using System.Collections.Generic;
-using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
@@ -20,9 +19,7 @@ namespace SendGridMail.Transport public const String JsonFormat = "json";
public const String XmlFormat = "xml";
- private readonly List<KeyValuePair<String, String>> _query;
private readonly NetworkCredential _credentials;
- private readonly NameValueCollection _queryParameters;
private readonly String _restEndpoint;
private readonly String _format;
#endregion
@@ -69,7 +66,7 @@ namespace SendGridMail.Transport #region Support Methods
- private HttpClient InitializeTransport(out MultipartEntity multipartEntity, out HttpPost postMethod)
+ internal HttpClient InitializeTransport(out MultipartEntity multipartEntity, out HttpPost postMethod)
{
var client = new HttpClient();
postMethod = new HttpPost(new Uri(_restEndpoint));
@@ -118,7 +115,7 @@ namespace SendGridMail.Transport }
}
- private List<KeyValuePair<String, String>> FetchFormParams(ISendGrid message)
+ internal List<KeyValuePair<String, String>> FetchFormParams(ISendGrid message)
{
var result = new List<KeyValuePair<string, string>>()
{
@@ -152,7 +149,7 @@ namespace SendGridMail.Transport return result.Where(r => !String.IsNullOrEmpty(r.Value)).ToList();
}
- private List<KeyValuePair<String, FileInfo>> FetchFileBodies(ISendGrid message)
+ internal List<KeyValuePair<String, FileInfo>> FetchFileBodies(ISendGrid message)
{
if(message.Attachments == null)
return new List<KeyValuePair<string, FileInfo>>();
diff --git a/SendGrid/SendGridMail/Transport/SMTP.cs b/SendGrid/SendGridMail/Transport/SMTP.cs index 606afcd..a878ce8 100755 --- a/SendGrid/SendGridMail/Transport/SMTP.cs +++ b/SendGrid/SendGridMail/Transport/SMTP.cs @@ -72,7 +72,7 @@ namespace SendGridMail.Transport /// <param name="credentials">Sendgrid user credentials</param>
/// <param name="host">MTA recieving this message. By default, sent through SendGrid.</param>
/// <param name="port">SMTP port 25 is the default. Port 465 can be used for Secure SMTP.</param>
- public static SMTP GenerateInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ public static SMTP GetInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
var client = new SmtpWrapper(host, port, credentials, SmtpDeliveryMethod.Network);
return new SMTP(client, credentials, host, port);
@@ -86,7 +86,7 @@ namespace SendGridMail.Transport /// <param name="host"></param>
/// <param name="port"></param>
/// <returns></returns>
- internal static SMTP GenerateInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ internal static SMTP GetInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
return new SMTP(client, credentials, host, port);
}
diff --git a/SendGrid/SendGridMail/lib/CodeScales.Http.dll b/SendGrid/SendGridMail/lib/CodeScales.Http.dll Binary files differnew file mode 100755 index 0000000..2509b52 --- /dev/null +++ b/SendGrid/SendGridMail/lib/CodeScales.Http.dll |