forked from lukencode/FluentEmail
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathIFluentEmail.cs
273 lines (237 loc) · 11 KB
/
IFluentEmail.cs
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
269
270
271
272
273
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using FluentEmail.Core.Interfaces;
using FluentEmail.Core.Models;
namespace FluentEmail.Core
{
public interface IFluentEmail: IHideObjectMembers
{
EmailData Data { get; set; }
ITemplateRenderer Renderer { get; set; }
ISender Sender { get; set; }
/// <summary>
/// Adds a recipient to the email, Splits name and address on ';'
/// </summary>
/// <param name="emailAddress">Email address of recipient</param>
/// <param name="name">Name of recipient</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail To(string emailAddress, string name = null);
/// <summary>
/// Set the send from email address
/// </summary>
/// <param name="emailAddress">Email address of sender</param>
/// <param name="name">Name of sender</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail SetFrom(string emailAddress, string name = null);
/// <summary>
/// Adds a recipient to the email
/// </summary>
/// <param name="emailAddress">Email address of recipient (allows multiple splitting on ';')</param>
/// <returns></returns>
IFluentEmail To(string emailAddress);
/// <summary>
/// Adds all recipients in list to email
/// </summary>
/// <param name="mailAddresses">List of recipients</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail To(IEnumerable<Address> mailAddresses);
/// <summary>
/// Adds all recipients in list to email
/// </summary>
/// <param name="mailAddresses">List of recipients</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail To(IEnumerable<string> mailAddresses);
/// <summary>
/// Adds all recipients in list to email
/// </summary>
/// <param name="mailAddresses">List of recipients</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail To(string[] mailAddresses);
/// <summary>
/// Adds a Carbon Copy to the email
/// </summary>
/// <param name="emailAddress">Email address to cc</param>
/// <param name="name">Name to cc</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail CC(string emailAddress, string name = "");
/// <summary>
/// Adds all Carbon Copy in list to an email
/// </summary>
/// <param name="mailAddresses">List of recipients to CC</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail CC(IEnumerable<Address> mailAddresses);
/// <summary>
/// Adds a blind carbon copy to the email
/// </summary>
/// <param name="emailAddress">Email address of bcc</param>
/// <param name="name">Name of bcc</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail BCC(string emailAddress, string name = "");
/// <summary>
/// Adds all blind carbon copy in list to an email
/// </summary>
/// <param name="mailAddresses">List of recipients to BCC</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail BCC(IEnumerable<Address> mailAddresses);
/// <summary>
/// Sets the ReplyTo address on the email
/// </summary>
/// <param name="address">The ReplyTo Address</param>
/// <returns></returns>
IFluentEmail ReplyTo(string address);
/// <summary>
/// Sets the ReplyTo address on the email
/// </summary>
/// <param name="address">The ReplyTo Address</param>
/// <param name="name">The Display Name of the ReplyTo</param>
/// <returns></returns>
IFluentEmail ReplyTo(string address, string name);
/// <summary>
/// Adds all recipients in list to email's ReplyTo list
/// </summary>
/// <param name="mailAddresses">List of recipients</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail ReplyTo(IEnumerable<string> mailAddresses);
/// <summary>
/// Adds all recipients in list to email's ReplyTo list
/// </summary>
/// <param name="mailAddresses">List of recipients</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail ReplyTo(string[] mailAddresses);
/// <summary>
/// Sets the subject of the email
/// </summary>
/// <param name="subject">email subject</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail Subject(string subject);
/// <summary>
/// Adds a Body to the Email
/// </summary>
/// <param name="body">The content of the body</param>
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param>
IFluentEmail Body(string body, bool isHtml = false);
/// <summary>
/// Marks the email as High Priority
/// </summary>
IFluentEmail HighPriority();
/// <summary>
/// Marks the email as Low Priority
/// </summary>
IFluentEmail LowPriority();
/// <summary>
/// Set the template rendering engine to use, defaults to RazorEngine
/// </summary>
IFluentEmail UsingTemplateEngine(ITemplateRenderer renderer);
/// <summary>
/// Adds template to email from embedded resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="path">Path the the embedded resource eg [YourAssembly].[YourResourceFolder].[YourFilename.txt]</param>
/// <param name="model">Model for the template</param>
/// <param name="assembly">The assembly your resource is in. Defaults to calling assembly.</param>
/// <returns></returns>
IFluentEmail UsingTemplateFromEmbedded<T>(string path, T model, Assembly assembly, bool isHtml = true);
/// <summary>
/// Adds the template file to the email
/// </summary>
/// <param name="filename">The path to the file to load</param>
/// <param name="model">Model for the template</param>
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail UsingTemplateFromFile<T>(string filename, T model, bool isHtml = true);
/// <summary>
/// Adds a culture specific template file to the email
/// </summary>
/// <param name="filename">The path to the file to load</param>
/// /// <param name="model">The razor model</param>
/// <param name="culture">The culture of the template (Default is the current culture)</param>
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail UsingCultureTemplateFromFile<T>(string filename, T model, CultureInfo culture, bool isHtml = true);
/// <summary>
/// Adds razor template to the email
/// </summary>
/// <param name="template">The razor template</param>
/// <param name="model">Model for the template</param>
/// <param name="isHtml">True if Body is HTML, false for plain text (Optional)</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail UsingTemplate<T>(string template, T model, bool isHtml = true);
/// <summary>
/// Adds an Attachment to the Email
/// </summary>
/// <param name="attachment">The Attachment to add</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail Attach(Attachment attachment);
/// <summary>
/// Adds Multiple Attachments to the Email
/// </summary>
/// <param name="attachments">The List of Attachments to add</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail Attach(IEnumerable<Attachment> attachments);
/// <summary>
/// Sends email synchronously
/// </summary>
/// <returns>Instance of the Email class</returns>
SendResponse Send(CancellationToken? token = null);
/// <summary>
/// Sends email asynchronously
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
Task<SendResponse> SendAsync(CancellationToken? token = null);
IFluentEmail AttachFromFilename(string filename, string contentType = null, string attachmentName = null);
/// <summary>
/// Adds a Plaintext alternative Body to the Email. Used in conjunction with an HTML email,
/// this allows for email readers without html capability, and also helps avoid spam filters.
/// </summary>
/// <param name="body">The content of the body</param>
IFluentEmail PlaintextAlternativeBody(string body);
/// <summary>
/// Adds template to email from embedded resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="path">Path the the embedded resource eg [YourAssembly].[YourResourceFolder].[YourFilename.txt]</param>
/// <param name="model">Model for the template</param>
/// <param name="assembly">The assembly your resource is in. Defaults to calling assembly.</param>
/// <returns></returns>
IFluentEmail PlaintextAlternativeUsingTemplateFromEmbedded<T>(string path, T model, Assembly assembly);
/// <summary>
/// Adds the template file to the email
/// </summary>
/// <param name="filename">The path to the file to load</param>
/// <param name="model">Model for the template</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail PlaintextAlternativeUsingTemplateFromFile<T>(string filename, T model);
/// <summary>
/// Adds a culture specific template file to the email
/// </summary>
/// <param name="filename">The path to the file to load</param>
/// /// <param name="model">The razor model</param>
/// <param name="culture">The culture of the template (Default is the current culture)</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail PlaintextAlternativeUsingCultureTemplateFromFile<T>(string filename, T model, CultureInfo culture);
/// <summary>
/// Adds razor template to the email
/// </summary>
/// <param name="template">The razor template</param>
/// <param name="model">Model for the template</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail PlaintextAlternativeUsingTemplate<T>(string template, T model);
/// <summary>
/// Adds tag to the Email. This is currently only supported by the Mailgun provider. <see href="https://documentation.mailgun.com/en/latest/user_manual.html#tagging"/>
/// </summary>
/// <param name="tag">Tag name, max 128 characters, ASCII only</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail Tag(string tag);
/// <summary>
/// Adds header to the Email.
/// </summary>
/// <param name="header">Header name, only printable ASCII allowed.</param>
/// <param name="body">value of the header</param>
/// <returns>Instance of the Email class</returns>
IFluentEmail Header(string header, string body);
}
}