Class EmailService
Implements IEmailService using the .NET SmtpClient 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.NetMail
Assembly: DataWeb.Email.NetMail.dll
Syntax
public class EmailService : IEmailService
Constructors
EmailService(IEnvironmentService, IConfigurationService)
Implements IEmailService using the .NET SmtpClient 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)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironmentService | environmentService | |
| IConfigurationService | configurationService |
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 configured SMTP server.
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. |