Class SendEmailRequestBuilder
A set of helper methods to streamline SendEmailRequest instance construction using fluent style.
public static class SendEmailRequestBuilder
- Inheritance
-
SendEmailRequestBuilder
Methods
Attach(SendEmailRequest, params Attachment[])
Adds provided attachments
to the Attachments
collection of the request
.
public static SendEmailRequest Attach(this SendEmailRequest request, params Attachment[] attachments)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
attachments
Attachment[]One or more Attachment objects to add to the request's Attachments collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Duplicates can be added by calling this method multiple times with the same Attachment object.
Exceptions
- ArgumentNullException
When
request
orattachments
is null.
Attach(SendEmailRequest, string, string, DispositionType?, string?, string?)
Adds provided attachment to the Attachments
collection of the request
.
public static SendEmailRequest Attach(this SendEmailRequest request, string content, string fileName, DispositionType? disposition = null, string? mimeType = null, string? contentId = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
content
string-
The Base64 encoded content of the attachment.
Required. Must be non-empty string.
fileName
string-
Attachment file name.
Required. Must be non-empty string.
disposition
DispositionType-
The attachment's content disposition, specifying how you would like the attachment to be displayed.
Optional. Defaults to Attachment if not specified explicitly.
mimeType
string-
Attachment MIME type identifier (e.g. "text/plain", "application/pdf", etc.)
Optional.
contentId
string-
The attachment's content ID.
Optional.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Duplicates can be added by calling this method multiple times with the same parameters.
Exceptions
- ArgumentNullException
When
request
is null.
Whencontent
is null or Empty.
WhenfileName
is null or Empty.
Bcc(SendEmailRequest, params EmailAddress[])
Adds provided recipients
to the Bcc
recipient collection of the request
.
public static SendEmailRequest Bcc(this SendEmailRequest request, params EmailAddress[] recipients)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
recipients
EmailAddress[]- One or more EmailAddress objects to add to the request's recipient collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
- ArgumentNullException
When
request
orrecipients
is null.
Bcc(SendEmailRequest, string, string?)
Adds provided email
and displayName
tuple as recipient
to the Bcc recipient collection of the request
.
public static SendEmailRequest Bcc(this SendEmailRequest request, string email, string? displayName = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
email
stringRecipient's email address.
Required. Must be valid email address.
displayName
string- Optional recipient's display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
Category(SendEmailRequest, string?)
Sets provided category
to the request
.
public static SendEmailRequest Category(this SendEmailRequest request, string? category)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
category
stringValue to initialize request's Category property.
Should be less or equal to 255 characters.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Value must remain null if TemplateId is used to create email from template.
Exceptions
- ArgumentNullException
When
request
is null.
Cc(SendEmailRequest, params EmailAddress[])
Adds provided recipients
to the Cc
recipient collection of the request
.
public static SendEmailRequest Cc(this SendEmailRequest request, params EmailAddress[] recipients)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
recipients
EmailAddress[]- One or more EmailAddress objects to add to the request's recipient collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
- ArgumentNullException
When
request
orrecipients
is null.
Cc(SendEmailRequest, string, string?)
Adds provided email
and displayName
tuple as recipient
to the Cc recipient collection of the request
.
public static SendEmailRequest Cc(this SendEmailRequest request, string email, string? displayName = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
email
stringRecipient's email address.
Required. Must be valid email address.
displayName
string- Optional recipient's display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
CustomVariable(SendEmailRequest, params KeyValuePair<string, string>[])
Adds provided variables
to the CustomVariables
collection of the request
.
public static SendEmailRequest CustomVariable(this SendEmailRequest request, params KeyValuePair<string, string>[] variables)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
variables
KeyValuePair<string, string>[]One or more key/value pairs to add to the request's CustomVariables collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Any existing variables with the same keys will be overridden.
Exceptions
- ArgumentNullException
When
request
orvariables
is null.
CustomVariable(SendEmailRequest, string, string)
Adds provided custom variable to the Headers
collection of the request
.
public static SendEmailRequest CustomVariable(this SendEmailRequest request, string key, string value)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
key
stringVariable key to add.
value
stringVariable value to add.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Any existing variable with the same key will be overridden.
Exceptions
From(SendEmailRequest, EmailAddress)
Sets provided sender
to the request
.
public static SendEmailRequest From(this SendEmailRequest request, EmailAddress sender)
Parameters
request
SendEmailRequestSendEmailRequest instance to update.
sender
EmailAddressEmailAddress object to initialize request's From property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Exceptions
- ArgumentNullException
When
request
orsender
is null.
From(SendEmailRequest, string, string?)
Sets provided email
and displayName
as sender
for the request
.
public static SendEmailRequest From(this SendEmailRequest request, string email, string? displayName = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
email
stringSender's email address.
Required. Must be valid email address.
displayName
stringOptional sender's display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
Header(SendEmailRequest, params KeyValuePair<string, string>[])
Adds provided headers
to the Headers
collection of the request
.
public static SendEmailRequest Header(this SendEmailRequest request, params KeyValuePair<string, string>[] headers)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
headers
KeyValuePair<string, string>[]One or more key/value pairs to add to the request's Headers collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Any existing headers with the same keys will be overridden.
Exceptions
- ArgumentNullException
When
request
orheaders
is null.
Header(SendEmailRequest, string, string)
Adds provided header to the Headers
collection of the request
.
public static SendEmailRequest Header(this SendEmailRequest request, string key, string value)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
key
stringHeader key to add.
value
stringHeader value to add.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Any existing header with the same key will be overridden.
Exceptions
Html(SendEmailRequest, string?)
Sets provided html
to the request
.
public static SendEmailRequest Html(this SendEmailRequest request, string? html)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
html
stringValue to initialize request's HtmlBody property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
It is a caller responsibility to ensure that html
contains a valid,
well-formed HTML markup and is sanitized properly.
Subsequent calls will override value that was set before (last wins).
Value must remain null if TemplateId is used to create email from template.
Exceptions
- ArgumentNullException
When
request
is null.
ReplyTo(SendEmailRequest, EmailAddress?)
Sets provided replyTo
address in the request
.
public static SendEmailRequest ReplyTo(this SendEmailRequest request, EmailAddress? replyTo)
Parameters
request
SendEmailRequestSendEmailRequest instance to update.
replyTo
EmailAddressEmailAddress object to initialize request's ReplyTo property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Exceptions
- ArgumentNullException
When
request
is null.
ReplyTo(SendEmailRequest, string, string?)
Sets provided email
and displayName
as 'Reply To' address
in the request
.
public static SendEmailRequest ReplyTo(this SendEmailRequest request, string email, string? displayName = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
email
string'Reply To' email address.
Required. Must be valid email address.
displayName
stringOptional 'Reply To' display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Exceptions
Subject(SendEmailRequest, string)
Sets provided subject
to the request
.
public static SendEmailRequest Subject(this SendEmailRequest request, string subject)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
subject
stringValue to initialize request's Subject property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Value must remain null if TemplateId is used to create email from template.
Exceptions
Template(SendEmailRequest, string)
Sets provided templateId
to the request
.
public static SendEmailRequest Template(this SendEmailRequest request, string templateId)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
templateId
stringValue containing UUID of the template to initialize request's TemplateId property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
When TemplateId is set, then Subject, TextBody, HtmlBody and Category properties are forbidden and must be set to null.
Exceptions
TemplateVariables(SendEmailRequest, object?)
Sets provided templateVariables
to the request
.
public static SendEmailRequest TemplateVariables(this SendEmailRequest request, object? templateVariables)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
templateVariables
objectValue containing object to initialize request's TemplateVariables property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Will be used only in case template is set.
Exceptions
- ArgumentNullException
When
request
is null.
Text(SendEmailRequest, string?)
Sets provided text
to the request
.
public static SendEmailRequest Text(this SendEmailRequest request, string? text)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
text
stringValue to initialize request's TextBody property.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Subsequent calls will override value that was set before (last wins).
Value must remain null if TemplateId is used to create email from template.
Exceptions
- ArgumentNullException
When
request
is null.
To(SendEmailRequest, params EmailAddress[])
Adds provided recipients
to the To
recipient collection of the request
.
public static SendEmailRequest To(this SendEmailRequest request, params EmailAddress[] recipients)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
recipients
EmailAddress[]One or more EmailAddress objects to add to the request's recipient collection.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.
Remarks
Duplicates can be added by calling this method multiple times with the same recipients.
Exceptions
- ArgumentNullException
When
request
orrecipients
is null.
To(SendEmailRequest, string, string?)
Adds provided email
and displayName
tuple as recipient
to the To recipient collection of the request
.
public static SendEmailRequest To(this SendEmailRequest request, string email, string? displayName = null)
Parameters
request
SendEmailRequest- SendEmailRequest instance to update.
email
stringRecipient's email address.
Required. Must be valid email address.
displayName
stringOptional recipient's display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.