Class EmailService
Implements IEmailService using the SendGrid API to deliver email messages.
When IsSaveAsFile is enabled in the email settings, messages are written to disk
as .eml files via a local SMTP pickup directory instead of being sent.
Implements
Inherited Members
Namespace: DataWeb.Email.SendGrid
Assembly: DataWeb.Email.SendGrid.dll
Syntax
public class EmailService : IEmailService
Constructors
EmailService(IEnvironmentService, IConfigurationService, IAppErrorService, ISendGridClient)
Implements IEmailService using the SendGrid API to deliver email messages.
When IsSaveAsFile is enabled in the email settings, messages are written to disk
as .eml files via a local SMTP pickup directory instead of being sent.
Declaration
public EmailService(IEnvironmentService environmentService, IConfigurationService configurationService, IAppErrorService appErrorService, ISendGridClient sendGridClient)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironmentService | environmentService | |
| IConfigurationService | configurationService | |
| IAppErrorService | appErrorService | |
| ISendGridClient | sendGridClient |
Properties
Name
Gets the display name of this email service provider.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
SendAsync(EmailMessage, CancellationToken)
Sends an email message asynchronously using the SendGrid API.
If IsSaveAsFile is enabled, the message is saved to disk instead.
Declaration
public Task SendAsync(EmailMessage message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| EmailMessage | message | The email message to send. Cannot be null. |
| CancellationToken | cancellationToken | A token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
| ArgumentException | Thrown when required message fields are missing or invalid. |