diff options
Diffstat (limited to 'SendGrid')
-rw-r--r-- | SendGrid/SendGridMail/ISendGrid.cs | 6 | ||||
-rw-r--r-- | SendGrid/SendGridMail/SendGrid.cs | 11 | ||||
-rw-r--r-- | SendGrid/SendGridMail/Transport/Web.cs | 4 |
3 files changed, 20 insertions, 1 deletions
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs index 1e61610..534e644 100644 --- a/SendGrid/SendGridMail/ISendGrid.cs +++ b/SendGrid/SendGridMail/ISendGrid.cs @@ -164,6 +164,12 @@ namespace SendGridMail /// <param name="headers">key substitutionValues pairs</param>
void AddHeaders(IDictionary<String, String> headers);
+ /// <summary>
+ /// Gets the list of embedded images
+ /// </summary>
+ /// <returns></returns>
+ IDictionary<string, string> GetEmbeddedImages();
+
#endregion
#region SMTP API Functions
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs index 06ce5cc..3d2c6e2 100644 --- a/SendGrid/SendGridMail/SendGrid.cs +++ b/SendGrid/SendGridMail/SendGrid.cs @@ -144,13 +144,14 @@ namespace SendGridMail public IHeader Header { get; set; }
public String Html { get; set; }
public String Text { get; set; }
-
+
#endregion
#region Methods for setting data
private List<String> _attachments = new List<String>();
private Dictionary<String, MemoryStream> _streamedAttachments = new Dictionary<string, MemoryStream>();
+ private Dictionary<String, String> _contentImages = new Dictionary<string, string>();
public void AddTo(String address)
{
@@ -232,6 +233,14 @@ namespace SendGridMail set { _attachments = value.ToList(); }
}
+ public void EmbedImage(String filename, String cid) {
+ _contentImages[filename] = cid;
+ }
+
+ public IDictionary<string, string> GetEmbeddedImages() {
+ return new Dictionary<string, string>(_contentImages);
+ }
+
public void AddSubstitution(String replacementTag, List<String> substitutionValues)
{
//let the system complain if they do something bad, since the function returns null
diff --git a/SendGrid/SendGridMail/Transport/Web.cs b/SendGrid/SendGridMail/Transport/Web.cs index 3aaa62f..7bb8e58 100644 --- a/SendGrid/SendGridMail/Transport/Web.cs +++ b/SendGrid/SendGridMail/Transport/Web.cs @@ -199,6 +199,10 @@ namespace SendGridMail result = result.Concat(message.Cc.ToList().Select(a => new KeyValuePair<String, String>("cc[]", a.Address)))
.ToList();
}
+ if (message.GetEmbeddedImages().Count > 0) {
+ result = result.Concat(message.GetEmbeddedImages().ToList().Select(x => new KeyValuePair<String, String>(string.Format("content[{0}]", x.Key), x.Value)))
+ .ToList();
+ }
return result.Where(r => !String.IsNullOrEmpty(r.Value)).ToList();
}
|