Table of Contents

Interface IEmailClient<TRequest, TResponse>

Namespace
Mailtrap.Emails
Assembly
Mailtrap.Abstractions.dll

Base Mailtrap API client for sending emails.

public interface IEmailClient<TRequest, TResponse> : IRestResource where TRequest : class where TResponse : class

Type Parameters

TRequest

The type of the email request object. One of SendEmailRequest or BatchEmailRequest.

TResponse

The type of the email response object. One of SendEmailResponse or BatchEmailResponse.

Inherited Members

Methods

Send(TRequest, CancellationToken)

Sends email, represented by the request, and returns send operation result.

Task<TResponse> Send(TRequest request, CancellationToken cancellationToken = default)

Parameters

request TRequest

Request object, containing email data.

cancellationToken CancellationToken

Token to control operation cancellation.

Returns

Task<TResponse>

TResponse instance with response data.

Remarks

Request is checked for validity before send.
ArgumentException is thrown if validation fails.

Exceptions

ArgumentNullException

When request is null.

ArgumentException

When request contains invalid data.

JsonException

When request serialization or API response deserialization fails for any reason.

TaskCanceledException

When operation is canceled by cancellationToken.

OperationCanceledException

When operation is canceled by cancellationToken.

HttpRequestException

When request to the API fails for any reason.

MailtrapApiException

When request failed for any other reason.