diff options
Diffstat (limited to 'SendGrid/SendGridMail')
-rw-r--r-- | SendGrid/SendGridMail/Mail.csproj | 5 | ||||
-rw-r--r-- | SendGrid/SendGridMail/Properties/AssemblyInfo.cs | 4 | ||||
-rw-r--r-- | SendGrid/SendGridMail/Transport/Web.cs | 40 | ||||
-rw-r--r-- | SendGrid/SendGridMail/packages.config | 1 |
4 files changed, 29 insertions, 21 deletions
diff --git a/SendGrid/SendGridMail/Mail.csproj b/SendGrid/SendGridMail/Mail.csproj index 9dcb4ad..b1f8f84 100644 --- a/SendGrid/SendGridMail/Mail.csproj +++ b/SendGrid/SendGridMail/Mail.csproj @@ -88,8 +88,9 @@ </DebugType>
</PropertyGroup>
<ItemGroup>
- <Reference Include="SendGrid.SmtpApi">
- <HintPath>..\packages\SendGrid.SmtpApi.1.1.3\lib\net40\SendGrid.SmtpApi.dll</HintPath>
+ <Reference Include="SendGrid.SmtpApi, Version=1.2.1.0, Culture=neutral, PublicKeyToken=2ae73662c35d80e4, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\SendGrid.SmtpApi.1.2.1\lib\net40\SendGrid.SmtpApi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
diff --git a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs index c2d2a11..4d2311c 100644 --- a/SendGrid/SendGridMail/Properties/AssemblyInfo.cs +++ b/SendGrid/SendGridMail/Properties/AssemblyInfo.cs @@ -48,5 +48,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("4.1.0")]
-[assembly: AssemblyFileVersion("4.1.0")]
\ No newline at end of file +[assembly: AssemblyVersion("5.1.0")]
+[assembly: AssemblyFileVersion("5.1.0")]
\ No newline at end of file diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs index 69fed4c..7abf104 100644 --- a/SendGrid/SendGridMail/Transport/Web.cs +++ b/SendGrid/SendGridMail/Transport/Web.cs @@ -23,29 +23,41 @@ namespace SendGrid public const String Endpoint = "/api/mail.send";
private readonly NetworkCredential _credentials;
+ private readonly TimeSpan _timeout;
#endregion
/// <summary>
- /// Creates a new Web interface for sending mail. Preference is using the Factory method.
+ /// Creates a new Web interface for sending mail
/// </summary>
/// <param name="credentials">SendGridMessage user parameters</param>
- /// <param name="https">Use https?</param>
public Web(NetworkCredential credentials)
{
_credentials = credentials;
+ _timeout = TimeSpan.FromSeconds(100);
}
+ /// <summary>
+ /// Creates a new Web interface for sending mail.
+ /// </summary>
+ /// <param name="credentials">SendGridMessage user parameters</param>
+ /// <param name="httpTimeout">HTTP request timeout</param>
+ public Web(NetworkCredential credentials, TimeSpan httpTimeout)
+ {
+ _credentials = credentials;
+ _timeout = httpTimeout;
+ }
+
/// <summary>
/// Delivers a message over SendGrid's Web interface
/// </summary>
/// <param name="message"></param>
public void Deliver(ISendGrid message)
{
- var client = new HttpClient
- {
- BaseAddress = new Uri("https://" + BaseUrl)
- };
+ var client = new HttpClient();
+
+ client.BaseAddress = new Uri("https://" + BaseUrl);
+ client.Timeout = _timeout;
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "sendgrid/" + version + ";csharp");
@@ -63,10 +75,10 @@ namespace SendGrid /// <param name="message"></param>
public async Task DeliverAsync(ISendGrid message)
{
- var client = new HttpClient
- {
- BaseAddress = new Uri("https://" + BaseUrl)
- };
+ var client = new HttpClient();
+
+ client.BaseAddress = new Uri("https://" + BaseUrl);
+ client.Timeout = _timeout;
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "sendgrid/" + version + ";csharp");
@@ -78,7 +90,7 @@ namespace SendGrid await CheckForErrorsAsync(response);
}
- #region Support Methods
+ #region Support Methods
private void AttachFormParams(ISendGrid message, MultipartFormDataContent content)
{
@@ -171,12 +183,6 @@ namespace SendGrid private static async Task CheckForErrorsAsync(HttpResponseMessage response)
{
- //transport error
- if (response.StatusCode != HttpStatusCode.OK)
- {
- throw new Exception(response.ReasonPhrase);
- }
-
var content = await response.Content.ReadAsStreamAsync();
var errors = GetErrorsInResponse(content);
diff --git a/SendGrid/SendGridMail/packages.config b/SendGrid/SendGridMail/packages.config index 003f620..606bf16 100644 --- a/SendGrid/SendGridMail/packages.config +++ b/SendGrid/SendGridMail/packages.config @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SendGrid.SmtpApi" version="1.1.3" targetFramework="net40" />
+ <package id="SendGrid.SmtpApi" version="1.2.1" targetFramework="net45" />
</packages>
|