Table of Contents

Interface IEmailSender

Namespace
Builvero.Application.Interfaces.Services
Assembly
Builvero.Application.dll

Defines the contract for sending emails via SendGrid using dynamic templates.

public interface IEmailSender

Remarks

All email sending operations use SendGrid dynamic templates configured in application settings. Template IDs are specified in SendGridOptions.

Methods

SendAdminUpdateEmailAsync(string, string, string, CancellationToken)

Sends an admin update email to a user using the AdminUpdates SendGrid template.

Task SendAdminUpdateEmailAsync(string toEmail, string toName, string htmlContent, CancellationToken ct = default)

Parameters

toEmail string

Recipient email address.

toName string

Recipient name (from profile FullName or email local-part if profile name is unavailable).

htmlContent string

Raw HTML content for the email body. This is sent as-is to the template's content_html dynamic field.

ct CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "AdminUpdates" SendGrid dynamic template (configured via SendGrid:AdminUpdatesTemplateId). The email subject is defined in the SendGrid template and cannot be overridden.

The template receives the following dynamic data:

  • content_html: The raw HTML content (triple-braced in template for unescaped rendering)
  • recipient_name: The recipient's name
  • current_year: The current year (for copyright/footer)
  • unsubscribe_url: URL for unsubscribing from admin updates

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved, template ID is not configured, or SendGrid API returns errors.

SendForumNewMessageAsync(User, Project, ProjectForumTopic, ProjectForumMessage, string, string, CancellationToken)

Sends a notification email when a new message is posted in a forum topic.

Task SendForumNewMessageAsync(User recipient, Project project, ProjectForumTopic topic, ProjectForumMessage message, string unsubscribeAllUrl, string unsubscribeTopicUrl, CancellationToken ct = default)

Parameters

recipient User

The user who should receive the notification.

project Project

The project containing the forum topic.

topic ProjectForumTopic

The forum topic where the message was posted.

message ProjectForumMessage

The newly posted forum message.

unsubscribeAllUrl string

URL for unsubscribing from all forum notifications.

unsubscribeTopicUrl string

URL for unsubscribing from notifications for this specific topic.

ct CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses a SendGrid dynamic template for forum message notifications. The email includes project information, topic title, and the new message content.

SendForumNewTopicAsync(User, Project, ProjectForumTopic, ProjectForumMessage, string, string, CancellationToken)

Sends a notification email when a new forum topic is created in a project.

Task SendForumNewTopicAsync(User recipient, Project project, ProjectForumTopic topic, ProjectForumMessage firstMessage, string unsubscribeAllUrl, string unsubscribeTopicUrl, CancellationToken ct = default)

Parameters

recipient User

The user who should receive the notification.

project Project

The project where the topic was created.

topic ProjectForumTopic

The newly created forum topic.

firstMessage ProjectForumMessage

The first message in the topic (typically the topic creator's initial post).

unsubscribeAllUrl string

URL for unsubscribing from all forum notifications.

unsubscribeTopicUrl string

URL for unsubscribing from notifications for this specific topic.

ct CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses a SendGrid dynamic template for forum topic notifications. The email includes project information, topic title, and the first message content.

SendHelloEmailAsync(string, CancellationToken)

Sends a "Hello" test email to verify SendGrid configuration.

Task SendHelloEmailAsync(string toEmail, CancellationToken cancellationToken = default)

Parameters

toEmail string

The recipient email address.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "Hello" SendGrid template (configured via SendGrid:HelloTemplateId). This method is primarily used for testing email service configuration.

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved or SendGrid API returns errors.

SendInvitationEmailAsync(string, string, string, string?, string?, string?, string?, CancellationToken)

Sends an invitation email to a recipient containing an invitation code and link.

Task SendInvitationEmailAsync(string toEmail, string invitationCode, string invitationLink, string? expiresAt, string? label, string? senderName, string? supportEmail, CancellationToken cancellationToken = default)

Parameters

toEmail string

The recipient email address.

invitationCode string

The invitation code to include in the email.

invitationLink string

The full invitation link URL.

expiresAt string

Optional expiration date of the invitation, formatted as a string.

label string

Optional label for the invitation.

senderName string

Optional name of the admin sending the invitation.

supportEmail string

Optional support email address to include in the email.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "Invitation" SendGrid dynamic template (configured via SendGrid:InvitationTemplateId). The template receives dynamic data: invitation_code, invitation_link, expires_at, label, sender_name, support_email, current_year.

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved, template ID is not configured, or SendGrid API returns errors.

SendVolunteerApplicationAcceptedEmailAsync(string, string, string, CancellationToken)

Sends an email notification when a volunteer application status is changed to "Accepted".

Task SendVolunteerApplicationAcceptedEmailAsync(string applicantEmail, string applicantName, string roleTitle, CancellationToken cancellationToken = default)

Parameters

applicantEmail string

The email address of the applicant.

applicantName string

The full name of the applicant.

roleTitle string

The title of the volunteer role they applied for.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "VolunteerApplicationAccepted" SendGrid dynamic template (configured via SendGrid:VolunteerApplicationAcceptedTemplateId).

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved, template ID is not configured, or SendGrid API returns errors.

SendVolunteerApplicationDeclinedEmailAsync(string, string, string, CancellationToken)

Sends an email notification when a volunteer application is declined/discarded.

Task SendVolunteerApplicationDeclinedEmailAsync(string applicantEmail, string applicantName, string roleTitle, CancellationToken cancellationToken = default)

Parameters

applicantEmail string

The email address of the applicant.

applicantName string

The full name of the applicant.

roleTitle string

The title of the volunteer role they applied for.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "VolunteerApplicationDeclined" SendGrid dynamic template (configured via SendGrid:VolunteerApplicationDeclinedTemplateId).

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved, template ID is not configured, or SendGrid API returns errors.

SendVolunteerApplicationWaitlistEmailAsync(string, string, string, CancellationToken)

Sends an email notification when a volunteer application status is changed to "Reviewed" (waitlist).

Task SendVolunteerApplicationWaitlistEmailAsync(string applicantEmail, string applicantName, string roleTitle, CancellationToken cancellationToken = default)

Parameters

applicantEmail string

The email address of the applicant.

applicantName string

The full name of the applicant.

roleTitle string

The title of the volunteer role they applied for.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Defines the contract for sending emails via SendGrid using dynamic templates.

Remarks

Uses the "VolunteerApplicationWaitlist" SendGrid dynamic template (configured via SendGrid:VolunteerApplicationWaitlistTemplateId).

Exceptions

ArgumentException

Thrown when email format is invalid.

InvalidOperationException

Thrown when SendGrid API key cannot be resolved, template ID is not configured, or SendGrid API returns errors.