EmailSender
Namespace: Proffer.Email.Internal
Sends templated or raw emails using configured providers.
public class EmailSender : Proffer.Email.IEmailSender
Inheritance Object → EmailSender
Implements IEmailSender
Constructors
EmailSender(IEnumerable<IEmailProviderType>, IOptions<EmailOptions>, IStorageFactory, ITemplateLoaderFactory)
Initializes a new instance of the EmailSender class.
public EmailSender(IEnumerable<IEmailProviderType> emailProviderTypes, IOptions<EmailOptions> options, IStorageFactory storageFactory, ITemplateLoaderFactory templateLoaderFactory)
Parameters
emailProviderTypes
IEnumerable<IEmailProviderType>
The email provider types.
options
IOptions<EmailOptions>
The Proffer.Email options.
storageFactory
IStorageFactory
The storage factory.
templateLoaderFactory
ITemplateLoaderFactory
The template loader factory.
Exceptions
Methods
SendEmailAsync(String, String, IEmailAddress[])
Sends an email.
public Task SendEmailAsync(string subject, string message, IEmailAddress[] to)
Parameters
subject
String
The subject.
message
String
The body as plain text.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendEmailAsync(IEmailAddress, String, String, IEmailAddress[])
Sends an email.
public Task SendEmailAsync(IEmailAddress from, string subject, string message, IEmailAddress[] to)
Parameters
from
IEmailAddress
The sender email address.
subject
String
The subject.
message
String
The body as plain text.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendEmailAsync(IEmailAddress, IEmailAddress, String, String, Boolean, IEmailAddress[])
Sends an email.
public Task SendEmailAsync(IEmailAddress from, IEmailAddress replyTo, string subject, string message, bool plainTextOnly, IEmailAddress[] to)
Parameters
from
IEmailAddress
The sender email address.
replyTo
IEmailAddress
The reply-to email address.
subject
String
The subject.
message
String
The body as plain text.
plainTextOnly
Boolean
If set to true the body shoud be sent as plain text only.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendEmailAsync(IEmailAddress, String, String, IEnumerable<IEmailAttachment>, IEmailAddress[])
Sends an email.
public Task SendEmailAsync(IEmailAddress from, string subject, string message, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to)
Parameters
from
IEmailAddress
The sender email address.
subject
String
The subject.
message
String
The body as plain text.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendEmailAsync(IEmailAddress, IEmailAddress, String, String, Boolean, IEnumerable<IEmailAttachment>, IEmailAddress[])
Sends an email.
public Task SendEmailAsync(IEmailAddress from, IEmailAddress replyTo, string subject, string message, bool plainTextOnly, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to)
Parameters
from
IEmailAddress
The sender email address.
replyTo
IEmailAddress
The reply-to email address.
subject
String
The subject.
message
String
The body as plain text.
plainTextOnly
Boolean
If set to true the body shoud be sent as plain text only.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendEmailAsync(IEmailAddress, String, String, IEnumerable<IEmailAttachment>, IEmailAddress[], IEmailAddress[], IEmailAddress[], IEmailAddress, Boolean)
Sends an email.
public Task SendEmailAsync(IEmailAddress from, string subject, string message, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to, IEmailAddress[] cc, IEmailAddress[] bcc, IEmailAddress replyTo, bool plainTextOnly)
Parameters
from
IEmailAddress
The sender email address.
subject
String
The subject.
message
String
The body as plain text.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
cc
IEmailAddress[]
The CC email recipients.
bcc
IEmailAddress[]
The BCC email recipients.
replyTo
IEmailAddress
The reply-to email address.
plainTextOnly
Boolean
If set to true the body shoud be sent as plain text only.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(String, T, IEmailAddress[])
Sends a templated email from the configured default sender email address.
public Task SendTemplatedEmailAsync<T>(string templateKey, T context, IEmailAddress[] to)
Type Parameters
T
The type of context to apply on the template.
Parameters
templateKey
String
The template key.
context
T
The context to apply on the template.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(IEmailAddress, String, T, IEmailAddress[])
Sends a templated email.
public Task SendTemplatedEmailAsync<T>(IEmailAddress from, string templateKey, T context, IEmailAddress[] to)
Type Parameters
T
The type of context to apply on the template.
Parameters
from
IEmailAddress
The sender email address.
templateKey
String
The template key.
context
T
The context to apply on the template.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(IEmailAddress, IEmailAddress, String, T, IEmailAddress[])
Sends a templated email.
public Task SendTemplatedEmailAsync<T>(IEmailAddress from, IEmailAddress replyTo, string templateKey, T context, IEmailAddress[] to)
Type Parameters
T
The type of context to apply on the template.
Parameters
from
IEmailAddress
The sender email address.
replyTo
IEmailAddress
The reply-to email address.
templateKey
String
The template key.
context
T
The context to apply on the template.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(IEmailAddress, String, T, IEnumerable<IEmailAttachment>, IEmailAddress[])
Sends a templated email.
public Task SendTemplatedEmailAsync<T>(IEmailAddress from, string templateKey, T context, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to)
Type Parameters
T
The type of context to apply on the template.
Parameters
from
IEmailAddress
The sender email address.
templateKey
String
The template key.
context
T
The context to apply on the template.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(IEmailAddress, IEmailAddress, String, T, IEnumerable<IEmailAttachment>, IEmailAddress[])
Sends a templated email.
public Task SendTemplatedEmailAsync<T>(IEmailAddress from, IEmailAddress replyTo, string templateKey, T context, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to)
Type Parameters
T
The type of context to apply on the template.
Parameters
from
IEmailAddress
The sender email address.
replyTo
IEmailAddress
The reply-to email address.
templateKey
String
The template key.
context
T
The context to apply on the template.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
Returns
A task that represents the asynchronous operation.
SendTemplatedEmailAsync<T>(IEmailAddress, String, T, IEnumerable<IEmailAttachment>, IEmailAddress[], IEmailAddress[], IEmailAddress[], IEmailAddress)
Sends a templated email.
public Task SendTemplatedEmailAsync<T>(IEmailAddress from, string templateKey, T context, IEnumerable<IEmailAttachment> attachments, IEmailAddress[] to, IEmailAddress[] cc, IEmailAddress[] bcc, IEmailAddress replyTo)
Type Parameters
T
The type of context to apply on the template.
Parameters
from
IEmailAddress
The sender email address.
templateKey
String
The template key.
context
T
The context to apply on the template.
attachments
IEnumerable<IEmailAttachment>
The file attachments.
to
IEmailAddress[]
The email recipients.
cc
IEmailAddress[]
The CC email recipients.
bcc
IEmailAddress[]
The BCC email recipients.
replyTo
IEmailAddress
The reply-to email address.
Returns
GetTemplateAsync(String, EmailTemplateType)
Gets the template asynchronous.
protected Task<ITemplate> GetTemplateAsync(string templateKey, EmailTemplateType templateType)
Parameters
templateKey
String
The template key.
templateType
EmailTemplateType
Type of the template.