summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail/MailBuilder.cs
diff options
context:
space:
mode:
authorShawn A. Luce <shawn@saluce.com>2014-05-15 16:59:50 -0500
committerShawn A. Luce <shawn@saluce.com>2014-05-15 16:59:50 -0500
commitf6a3e659081c641b45f94978fd59df5244d5c4d3 (patch)
tree763d16295c96a1259a8e8a2d8144a963ee81a221 /SendGrid/SendGridMail/MailBuilder.cs
parent64bf5a7ea806cf8974c239e9faab50020d8e8079 (diff)
downloadsendgrid-csharp-f6a3e659081c641b45f94978fd59df5244d5c4d3.zip
sendgrid-csharp-f6a3e659081c641b45f94978fd59df5244d5c4d3.tar.gz
sendgrid-csharp-f6a3e659081c641b45f94978fd59df5244d5c4d3.tar.bz2
Added support for inline images and minor name changes in the MailBuilder
Diffstat (limited to 'SendGrid/SendGridMail/MailBuilder.cs')
-rw-r--r--SendGrid/SendGridMail/MailBuilder.cs50
1 files changed, 26 insertions, 24 deletions
diff --git a/SendGrid/SendGridMail/MailBuilder.cs b/SendGrid/SendGridMail/MailBuilder.cs
index 1d3d611..2457d2e 100644
--- a/SendGrid/SendGridMail/MailBuilder.cs
+++ b/SendGrid/SendGridMail/MailBuilder.cs
@@ -1,10 +1,10 @@
-using Smtpapi;
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mail;
using System.Text;
+using Smtpapi;
namespace SendGridMail {
public sealed class MailBuilder {
@@ -124,7 +124,7 @@ namespace SendGridMail {
public MailBuilder Html(AlternateView view) {
return this
.Html(GetAlternateViewAsString(view))
- .WithLinkedResources(view.LinkedResources);
+ .EmbedImages(view.LinkedResources);
}
public MailBuilder Html(string html) {
sendgrid.Html = html;
@@ -140,62 +140,64 @@ namespace SendGridMail {
return this;
}
- public MailBuilder WithAttachment(Stream stream, string name) {
+ public MailBuilder AttachFile(Stream stream, string name) {
sendgrid.AddAttachment(stream, name);
return this;
}
- public MailBuilder WithAttachment(string filePath) {
+ public MailBuilder AttachFile(string filePath) {
sendgrid.AddAttachment(filePath);
return this;
}
- public MailBuilder WithAttachment(Attachment attachment) {
- return this.WithAttachment(attachment.ContentStream, attachment.Name);
+ public MailBuilder AttachFile(Attachment attachment) {
+ return this.AttachFile(attachment.ContentStream, attachment.Name);
}
- public MailBuilder WithAttachments(IEnumerable<Attachment> attachments) {
- foreach (var attachment in attachments) { this.WithAttachment(attachment); }
+ public MailBuilder AttachFiles(IEnumerable<Attachment> attachments) {
+ foreach (var attachment in attachments) { this.AttachFile(attachment); }
return this;
}
- public MailBuilder WithAttachments(AttachmentCollection attachments) {
- return this.WithAttachments(attachments.ToList());
+ public MailBuilder AttachFiles(AttachmentCollection attachments) {
+ return this.AttachFiles(attachments.ToList());
}
- public MailBuilder WithLinkedResource(Stream stream, string name) {
+ public MailBuilder EmbedImage(Stream stream, string name, string cid) {
sendgrid.AddAttachment(stream, name);
+ sendgrid.EmbedImage(name, cid);
return this;
}
- public MailBuilder WithLinkedResource(string filePath) {
+ public MailBuilder EmbedImage(string filePath, string cid) {
sendgrid.AddAttachment(filePath);
+ sendgrid.EmbedImage(new FileInfo(filePath).Name, cid);
return this;
}
- public MailBuilder WithLinkedResource(LinkedResource resource) {
- return this.WithAttachment(resource.ContentStream, resource.ContentId);
+ public MailBuilder EmbedImage(LinkedResource resource) {
+ return this.EmbedImage(resource.ContentStream, resource.ContentId, resource.ContentId);
}
- public MailBuilder WithLinkedResources(IEnumerable<LinkedResource> resources) {
- foreach (var resource in resources) { this.WithLinkedResource(resource); }
+ public MailBuilder EmbedImages(IEnumerable<LinkedResource> resources) {
+ foreach (var resource in resources) { this.EmbedImage(resource); }
return this;
}
- public MailBuilder WithLinkedResources(LinkedResourceCollection resources) {
- return this.WithLinkedResources(resources.ToList());
+ public MailBuilder EmbedImages(LinkedResourceCollection resources) {
+ return this.EmbedImages(resources.ToList());
}
- public MailBuilder WithHeader(string key, string value) {
+ public MailBuilder AddHeader(string key, string value) {
sendgrid.AddHeaders(new Dictionary<string, string> { { key, value } });
return this;
}
- public MailBuilder WithHeaders(IDictionary<string, string> headers) {
+ public MailBuilder AddHeaders(IDictionary<string, string> headers) {
sendgrid.AddHeaders(headers);
return this;
}
- public MailBuilder WithSubstitution(string replacementTag, IEnumerable<string> substitutionValues) {
+ public MailBuilder Substitute(string replacementTag, IEnumerable<string> substitutionValues) {
sendgrid.AddSubstitution(replacementTag, substitutionValues.ToList());
return this;
}
- public MailBuilder WithUniqueArg(string key, string value) {
+ public MailBuilder IncludeUniqueArg(string key, string value) {
sendgrid.AddUniqueArgs(new Dictionary<string, string> { { key, value } });
return this;
}
- public MailBuilder WithUniqueArgs(IDictionary<string, string> identifiers) {
+ public MailBuilder IncludeUniqueArgs(IDictionary<string, string> identifiers) {
sendgrid.AddUniqueArgs(identifiers);
return this;
}