summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail/SendGrid.cs
diff options
context:
space:
mode:
authorbrandonmwest <brawest@gmail.com>2012-07-13 15:11:29 -0700
committerbrandonmwest <brawest@gmail.com>2012-07-13 15:11:29 -0700
commit1e3816f93799c66c59ad89e01ee42c858ffda0a9 (patch)
treec6c45dcce65a962a262f3818e012762347c231b1 /SendGrid/SendGridMail/SendGrid.cs
parent2a9fcb7557b8054ae6550898a9f796f40ec59c75 (diff)
parentcbfe73a74a42120d3c061633c45e1c99f1921ae2 (diff)
downloadsendgrid-csharp-1e3816f93799c66c59ad89e01ee42c858ffda0a9.zip
sendgrid-csharp-1e3816f93799c66c59ad89e01ee42c858ffda0a9.tar.gz
sendgrid-csharp-1e3816f93799c66c59ad89e01ee42c858ffda0a9.tar.bz2
Merge pull request #7 from brandonmwest/master
Merge streaming-attachments branch, add test for X-SMTPAPI header "to" array
Diffstat (limited to 'SendGrid/SendGridMail/SendGrid.cs')
-rwxr-xr-xSendGrid/SendGridMail/SendGrid.cs27
1 files changed, 25 insertions, 2 deletions
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 42214b7..3f2878f 100755
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
@@ -275,6 +276,13 @@ namespace SendGridMail
}
}
+ private Dictionary<String, MemoryStream> _streamedAttachments = new Dictionary<string, MemoryStream>();
+ public Dictionary<String, MemoryStream> StreamedAttachments
+ {
+ get { return _streamedAttachments; }
+ set { _streamedAttachments = value; }
+ }
+
private List<String> _attachments = new List<String>();
public String[] Attachments
{
@@ -297,8 +305,14 @@ namespace SendGridMail
{
Header.SetCategory(category);
}
-
-
+
+ public void AddAttachment(Stream stream, String name)
+ {
+ MemoryStream ms = new MemoryStream();
+ stream.CopyTo(ms);
+ StreamedAttachments[name] = ms;
+ }
+
public void AddAttachment(String filePath)
{
_attachments.Add(filePath);
@@ -496,6 +510,15 @@ namespace SendGridMail
}
}
+ if(StreamedAttachments != null)
+ {
+ foreach (var attachment in StreamedAttachments)
+ {
+ attachment.Value.Position = 0;
+ message.Attachments.Add(new Attachment(attachment.Value, attachment.Key));
+ }
+ }
+
if (Text != null)
{
AlternateView plainView = AlternateView.CreateAlternateViewFromString(Text, null, "text/plain");