-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendEmailRequest.cs
More file actions
178 lines (147 loc) · 5.05 KB
/
SendEmailRequest.cs
File metadata and controls
178 lines (147 loc) · 5.05 KB
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
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
namespace RamsonDevelopers.UtilEmail
{
/// <summary>
/// DTO for Sending an Email
/// </summary>
public class SendEmailRequest
{
/// <summary>
/// Email address of the Sender <see cref="EmailAddress"/>
/// </summary>
public EmailAddress FromAddress { get; set; }
/// <summary>
/// List of email addresses to send email to. <see cref="EmailAddress"/>
/// </summary>
public List<EmailAddress> ToAddresses { get; set; }
/// <summary>
/// List of email addresses to include in CC <see cref="EmailAddress"/>
/// </summary>
public List<EmailAddress> CcAddresses { get; set; }
/// <summary>
/// List of email addresses to include in BCC <see cref="EmailAddress"/>
/// </summary>
public List<EmailAddress> BccAddresses { get; set; }
/// <summary>
/// The subject of the Email
/// </summary>
public string Subject { get; set; } = string.Empty;
/// <summary>
/// Body of the email message
/// </summary>
public string Body { get; set; } = string.Empty;
/// <summary>
/// State weather the body is in HTML format
/// </summary>
public bool IsHtml { get; set; } = true;
/// <summary>
/// Set the Email's Priority. <see cref="EMailPriority"/>
/// </summary>
public EMailPriority Priority { get; set; } = EMailPriority.High;
/// <summary>
/// State Id
/// </summary>
public string EmailStateId { get; set; } = string.Empty;
/// <summary>
/// List of attachments to be shared with the email
/// </summary>
public List<Attachment> Attachments { get; set; }
/// <summary>
/// Linked resources for the attachments. <see cref="LinkedResource"/>
/// </summary>
public List<LinkedResource> LinkedResources { get; set; } = new List<LinkedResource>();
/// <summary>
/// List of values for all the variables present in the HTML template or message body.
/// <see cref="EmailTemplateVariables"/>
/// </summary>
public List<EmailTemplateVariables> Variables { get; set; }
/// <summary>
/// Default constructor
/// <param name="variables">A List of all the template variables</param>
/// </summary>
public SendEmailRequest(params EmailTemplateVariables[] variables)
{
ToAddresses = new List<EmailAddress>();
CcAddresses = new List<EmailAddress>();
BccAddresses = new List<EmailAddress>();
Variables = variables.ToList();
}
/// <summary>
/// Absolute Path for HTML Template
/// </summary>
public string TemplatePath { get; set; }
}
/// <summary>
/// Object for providing values to the variables present in the message body or HTML Template.
/// </summary>
public class EmailTemplateVariables
{
/// <summary>
/// Name of the variable
/// </summary>
public string Name { get; set; }
/// <summary>
/// Value to replace the variable placeholder with
/// </summary>
public string Value { get; set; }
/// <summary>
/// Set Values of <see cref="Name"/> and <see cref="Value"/> property through constructor to reduce code.
/// </summary>
/// <param name="name">Name of the template variable</param>
/// <param name="value">Value for the template variable</param>
public EmailTemplateVariables(string name, string value)
{
Name = name;
Value = value;
}
}
/// <summary>
/// The template or format of the Email address
/// </summary>
public class EmailAddress
{
private string _name = string.Empty;
/// <summary>
/// Name of the person whose email address is provided
/// </summary>
public string Name
{
get => string.IsNullOrEmpty(_name) ? Address : _name;
set => _name = value;
}
/// <summary>
/// Email address of the person
/// </summary>
public string Address { get; set; }
/// <summary>
/// Set the name and email address
/// </summary>
/// <param name="name">Name of the person</param>
/// <param name="address">Email Address of that person</param>
public EmailAddress(string name, string address)
{
Name = name;
Address = address;
}
}
/// <summary>
/// Enums for EmailPriority
/// </summary>
public enum EMailPriority
{
/// <summary>
/// set email priority to low
/// </summary>
Low,
/// <summary>
/// set email priority to Medium
/// </summary>
Medium,
/// <summary>
/// set email priority to HIGH
/// </summary>
High,
}
}