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
requestSendEmailRequest- SendEmailRequest instance to update.
attachmentsAttachment[]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
requestorattachmentsis 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
requestSendEmailRequest- SendEmailRequest instance to update.
contentstring-
The Base64 encoded content of the attachment.
Required. Must be non-empty string.
fileNamestring-
Attachment file name.
Required. Must be non-empty string.
dispositionDispositionType-
The attachment's content disposition, specifying how you would like the attachment to be displayed.
Optional. Defaults to Attachment if not specified explicitly.
mimeTypestring-
Attachment MIME type identifier (e.g. "text/plain", "application/pdf", etc.)
Optional.
contentIdstring-
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
requestis null.
Whencontentis null or Empty.
WhenfileNameis 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
requestSendEmailRequest- SendEmailRequest instance to update.
recipientsEmailAddress[]- 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
requestorrecipientsis 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
requestSendEmailRequest- SendEmailRequest instance to update.
emailstringRecipient's email address.
Required. Must be valid email address.
displayNamestring- 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
requestSendEmailRequest- SendEmailRequest instance to update.
categorystringValue 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
requestis 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
requestSendEmailRequest- SendEmailRequest instance to update.
recipientsEmailAddress[]- 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
requestorrecipientsis 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
requestSendEmailRequest- SendEmailRequest instance to update.
emailstringRecipient's email address.
Required. Must be valid email address.
displayNamestring- 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
requestSendEmailRequest- SendEmailRequest instance to update.
variablesKeyValuePair<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
requestorvariablesis 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
requestSendEmailRequest- SendEmailRequest instance to update.
keystringVariable key to add.
valuestringVariable 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
requestSendEmailRequestSendEmailRequest instance to update.
senderEmailAddressEmailAddress 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
requestorsenderis 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
requestSendEmailRequest- SendEmailRequest instance to update.
emailstringSender's email address.
Required. Must be valid email address.
displayNamestringOptional 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
requestSendEmailRequest- SendEmailRequest instance to update.
headersKeyValuePair<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
requestorheadersis 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
requestSendEmailRequest- SendEmailRequest instance to update.
keystringHeader key to add.
valuestringHeader 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
requestSendEmailRequest- SendEmailRequest instance to update.
htmlstringValue 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
requestis null.
ReplyTo(SendEmailRequest, EmailAddress?)
Sets provided replyTo address in the request.
public static SendEmailRequest ReplyTo(this SendEmailRequest request, EmailAddress? replyTo)
Parameters
requestSendEmailRequestSendEmailRequest instance to update.
replyToEmailAddressEmailAddress 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
requestis 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
requestSendEmailRequest- SendEmailRequest instance to update.
emailstring'Reply To' email address.
Required. Must be valid email address.
displayNamestringOptional '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
requestSendEmailRequest- SendEmailRequest instance to update.
subjectstringValue 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
requestSendEmailRequest- SendEmailRequest instance to update.
templateIdstringValue 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
requestSendEmailRequest- SendEmailRequest instance to update.
templateVariablesobjectValue 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
requestis null.
Text(SendEmailRequest, string?)
Sets provided text to the request.
public static SendEmailRequest Text(this SendEmailRequest request, string? text)
Parameters
requestSendEmailRequest- SendEmailRequest instance to update.
textstringValue 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
requestis 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
requestSendEmailRequest- SendEmailRequest instance to update.
recipientsEmailAddress[]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
requestorrecipientsis 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
requestSendEmailRequest- SendEmailRequest instance to update.
emailstringRecipient's email address.
Required. Must be valid email address.
displayNamestringOptional recipient's display name.
Returns
- SendEmailRequest
Updated SendEmailRequest instance so subsequent calls can be chained.