1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Mail;
namespace SendGridMail
{
/// <summary>
/// Represents the basic set of functions that will be called by the user
/// includes basic message data manipulation and filter settings
/// </summary>
public interface ISendGrid
{
#region Properties
MailAddress From { get; set; }
MailAddress[] To { get; set; }
MailAddress[] Cc { get; }
MailAddress[] Bcc { get; }
MailAddress[] ReplyTo { get; set; }
Dictionary<String, MemoryStream> StreamedAttachments { get; set; }
String[] Attachments { get; set; }
String Subject { get; set; }
Dictionary<String, String> Headers { get; set; }
IHeader Header { get; set; }
String Html { get; set; }
String Text { get; set; }
#endregion
#region Interface for ITransport
/// <summary>
/// Used by the Transport object to create a MIME for SMTP
/// </summary>
/// <returns>MIME to be sent</returns>
MailMessage CreateMimeMessage();
#endregion
#region Methods for setting data
/// <summary>
/// Add to the 'To' address.
/// </summary>
/// <param name="address">single string eg. 'you@company.com'</param>
void AddTo(String address);
/// <summary>
/// Add to the 'To' address.
/// </summary>
/// <param name="addresses">list of email addresses as strings</param>
void AddTo(IEnumerable<String> addresses);
/// <summary>
/// Add to the 'To' address.
/// </summary>
/// <param name="addresssInfo"> the dictionary keys are the email addresses, which points to a dictionary of
/// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } } </param>
void AddTo(IDictionary<String, IDictionary<String, String>> addresssInfo);
/// <summary>
/// Add to the 'CC' address.
/// </summary>
/// <param name="address">a single email address eg "you@company.com"</param>
void AddCc(String address);
/// <summary>
/// Add to the 'CC' address.
/// </summary>
/// <param name="addresses">a list of email addresses as strings</param>
void AddCc(IEnumerable<String> addresses);
/// <summary>
/// Add to the 'CC' address.
/// </summary>
/// <param name="addresssInfo">the dictionary keys are the email addresses, which points to a dictionary of
/// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } } </param>
void AddCc(IDictionary<String, IDictionary<String, String>> addresssInfo);
/// <summary>
/// Add to the 'Bcc' address.
/// </summary>
/// <param name="address">a single email as the input eg "you@company.com"</param>
void AddBcc(String address);
/// <summary>
/// Add to the 'Bcc' address.
/// </summary>
/// <param name="addresses">a list of emails as an array of strings.</param>
void AddBcc(IEnumerable<String> addresses);
/// <summary>
/// Add to the 'Bcc' address.
/// </summary>
/// <param name="addresssInfo">the dictionary keys are the email addresses, which points to a dictionary of
/// key substitutionValues pairs mapping to other address codes, such as { foo@bar.com => { 'DisplayName' => 'Mr Foo' } }</param>
void AddBcc(IDictionary<String, IDictionary<String, String>> addresssInfo);
/// <summary>
/// Defines a mapping between a replacement string in the text of the message to a list of
/// substitution values to be used, one per each recipient, in the same order as the recipients were added.
/// </summary>
/// <param name="replacementTag">the string in the email that you'll replace eg. '-name-'</param>
/// <param name="substitutionValues">a list of values that will be substituted in for the replacementTag, one for each recipient</param>
void AddSubVal(String replacementTag, List<String> substitutionValues);
/// <summary>
/// This adds parameters and values that will be bassed back through SendGrid's
/// Event API if an event notification is triggered by this email.
/// </summary>
/// <param name="identifiers">parameter substitutionValues pairs to be passed back on event notification</param>
void AddUniqueIdentifiers(IDictionary<String, String> identifiers);
/// <summary>
/// This sets the category for this email. Statistics are stored on a per category
/// basis, so this can be useful for tracking on a per group basis.
/// </summary>
/// <param name="category">categories applied to the message</param>
void SetCategory(String category);
/// <summary>
/// Add an attachment to the message.
/// </summary>
/// <param name="filePath">a fully qualified file path as a string</param>
void AddAttachment(String filePath);
/// <summary>
/// Add a stream as an attachment to the message
/// </summary>
/// <param name="stream">Stream of file to be attached</param>
/// <param name="name">Name of file to be attached</param>
void AddAttachment(Stream stream, String name);
/// <summary>
/// GetRecipients returns a list of all the recepients by retrieving the to, cc, and bcc lists.
/// </summary>
/// <returns></returns>
IEnumerable<String> GetRecipients();
/// <summary>
/// Add custom headers to the message
/// </summary>
/// <param name="headers">key substitutionValues pairs</param>
void AddHeaders(IDictionary<String, String> headers);
#endregion
#region SMTP API Functions
/// <summary>
/// Disable the gravatar app
/// </summary>
void DisableGravatar();
/// <summary>
/// Disable the open tracking app
/// </summary>
void DisableOpenTracking();
/// <summary>
/// Disable the click tracking app
/// </summary>
void DisableClickTracking();
/// <summary>
/// Disable the spam check
/// </summary>
void DisableSpamCheck();
/// <summary>
/// Disable the unsubscribe app
/// </summary>
void DisableUnsubscribe();
/// <summary>
/// Disable the footer app
/// </summary>
void DisableFooter();
/// <summary>
/// Disable the Google Analytics app
/// </summary>
void DisableGoogleAnalytics();
/// <summary>
/// Disable the templates app
/// </summary>
void DisableTemplate();
/// <summary>
/// Disable Bcc app
/// </summary>
void DisableBcc();
/// <summary>
/// Disable the Bypass List Management app
/// </summary>
void DisableBypassListManagement();
/// <summary>
/// Inserts the gravatar image of the sender to the bottom of the message
/// </summary>
void EnableGravatar();
/// <summary>
/// Adds an invisible image to the end of the email which can track e-mail opens.
/// </summary>
void EnableOpenTracking();
/// <summary>
/// Causes all links to be overwritten, shortened, and pointed to SendGrid's servers so clicks will be tracked.
/// </summary>
/// <param name="includePlainText">true if links found in plain text portions of the message are to be overwritten</param>
void EnableClickTracking(bool includePlainText = false);
/// <summary>
/// Provides notification when emails are deteched that exceed a predefined spam threshold.
/// </summary>
/// <param name="score">Emails with a SpamAssassin score over this substitutionValues will be considered spam and not be delivered.</param>
/// <param name="url">SendGrid will send an HTTP POST request to this url when a message is detected as spam</param>
void EnableSpamCheck(int score = 5, String url = null);
/// <summary>
/// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
/// </summary>
/// <param name="text">String for the plain text email body showing what you want the message to look like.</param>
/// <param name="html">String for the HTML email body showing what you want the message to look like.</param>
void EnableUnsubscribe(String text, String html);
/// <summary>
/// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
/// </summary>
/// <param name="replace">Tag in the message body to be replaced with the unsubscribe link and message</param>
void EnableUnsubscribe(String replace);
/// <summary>
/// Attaches a message at the footer of the email
/// </summary>
/// <param name="text">Message for the plain text body of the email</param>
/// <param name="html">Message for the HTML body of the email</param>
void EnableFooter(String text = null, String html = null);
/// <summary>
/// Re-writes links to integrate with Google Analytics
/// </summary>
/// <param name="source">Name of the referrer source (e.g. Google, SomeDomain.com, NewsletterA)</param>
/// <param name="medium">Name of the marketing medium (e.g. Email)</param>
/// <param name="term">Identify paid keywords</param>
/// <param name="content">Use to differentiate ads</param>
/// <param name="campaign">Name of the campaign</param>
void EnableGoogleAnalytics(String source, String medium, String term, String content = null, String campaign = null);
/// <summary>
/// Wraps an HTML template around your email content.
/// </summary>
/// <param name="html">HTML that your emails will be wrapped in, containing a body replacementTag.</param>
void EnableTemplate(String html = null);
/// <summary>
/// Automatically sends a blind carbon copy to an address for every e-mail sent, without
/// adding that address to the header.
/// </summary>
/// <param name="email">A single email recipient</param>
void EnableBcc(String email = null);
/// <summary>
/// Enabing this app will bypass the normal unsubscribe / bounce / spam report checks
/// and queue the e-mail for delivery.
/// </summary>
void EnableBypassListManagement();
#endregion
}
}
|