diff options
author | tmwilson <tom.wilson@alpinemetrics.com> | 2015-01-28 10:04:41 -0700 |
---|---|---|
committer | tmwilson <tom.wilson@alpinemetrics.com> | 2015-01-28 10:04:41 -0700 |
commit | a4cccbd5e81d84e64c857e1d8f68335edcb482d7 (patch) | |
tree | 824fe266656efd5dc4be8aa27cee91b21490a080 | |
parent | 6354302c92e8994b44ae8fc89a992ad4ffca5b6d (diff) | |
download | sendgrid-csharp-a4cccbd5e81d84e64c857e1d8f68335edcb482d7.zip sendgrid-csharp-a4cccbd5e81d84e64c857e1d8f68335edcb482d7.tar.gz sendgrid-csharp-a4cccbd5e81d84e64c857e1d8f68335edcb482d7.tar.bz2 |
adding ability to embed an image via a memory stream. I'm generating an image and then transferring it to memory stream right away. This prevents you from having to create a file if you already have a memory stream.
-rw-r--r-- | SendGrid/SendGridMail/ISendGrid.cs | 2 | ||||
-rw-r--r-- | SendGrid/SendGridMail/SendGrid.cs | 10 | ||||
-rw-r--r-- | SendGrid/SendGridMail/StreamedFileBody.cs | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs index 1d5ea8f..b4fcdc9 100644 --- a/SendGrid/SendGridMail/ISendGrid.cs +++ b/SendGrid/SendGridMail/ISendGrid.cs @@ -108,6 +108,8 @@ namespace SendGrid /// <param name="name">Name of file to be attached</param>
void AddAttachment(Stream stream, String name);
+ void EmbedStreamImage(Stream stream, String name);
+
/// <summary>
/// GetRecipients returns a list of all the recepients by retrieving the to, cc, and bcc lists.
/// </summary>
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs index 1533a46..9d43dc2 100644 --- a/SendGrid/SendGridMail/SendGrid.cs +++ b/SendGrid/SendGridMail/SendGrid.cs @@ -245,6 +245,16 @@ namespace SendGrid StreamedAttachments[name] = ms;
}
+ public void EmbedStreamImage(Stream stream, String name)
+ {
+ var ms = new MemoryStream();
+ stream.CopyTo(ms);
+ ms.Seek(0, SeekOrigin.Begin);
+ StreamedAttachments[name] = ms;
+
+ _contentImages[name] = name;
+ }
+
public void AddAttachment(String filePath)
{
_attachments.Add(filePath);
diff --git a/SendGrid/SendGridMail/StreamedFileBody.cs b/SendGrid/SendGridMail/StreamedFileBody.cs index faa9d59..125fe24 100644 --- a/SendGrid/SendGridMail/StreamedFileBody.cs +++ b/SendGrid/SendGridMail/StreamedFileBody.cs @@ -6,7 +6,7 @@ using System.Text; namespace SendGridMail
{
- public class StreamedFileBody : Body
+ public class StreamedFileBody
{
private string _name;
private string _filename;
|