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
toEmailstringRecipient email address.
toNamestringRecipient name (from profile FullName or email local-part if profile name is unavailable).
htmlContentstringRaw HTML content for the email body. This is sent as-is to the template's
content_htmldynamic field.ctCancellationTokenCancellation 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 namecurrent_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
recipientUserThe user who should receive the notification.
projectProjectThe project containing the forum topic.
topicProjectForumTopicThe forum topic where the message was posted.
messageProjectForumMessageThe newly posted forum message.
unsubscribeAllUrlstringURL for unsubscribing from all forum notifications.
unsubscribeTopicUrlstringURL for unsubscribing from notifications for this specific topic.
ctCancellationTokenCancellation 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
recipientUserThe user who should receive the notification.
projectProjectThe project where the topic was created.
topicProjectForumTopicThe newly created forum topic.
firstMessageProjectForumMessageThe first message in the topic (typically the topic creator's initial post).
unsubscribeAllUrlstringURL for unsubscribing from all forum notifications.
unsubscribeTopicUrlstringURL for unsubscribing from notifications for this specific topic.
ctCancellationTokenCancellation 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
toEmailstringThe recipient email address.
cancellationTokenCancellationTokenCancellation 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
toEmailstringThe recipient email address.
invitationCodestringThe invitation code to include in the email.
invitationLinkstringThe full invitation link URL.
expiresAtstringOptional expiration date of the invitation, formatted as a string.
labelstringOptional label for the invitation.
senderNamestringOptional name of the admin sending the invitation.
supportEmailstringOptional support email address to include in the email.
cancellationTokenCancellationTokenCancellation 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
applicantEmailstringThe email address of the applicant.
applicantNamestringThe full name of the applicant.
roleTitlestringThe title of the volunteer role they applied for.
cancellationTokenCancellationTokenCancellation 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
applicantEmailstringThe email address of the applicant.
applicantNamestringThe full name of the applicant.
roleTitlestringThe title of the volunteer role they applied for.
cancellationTokenCancellationTokenCancellation 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
applicantEmailstringThe email address of the applicant.
applicantNamestringThe full name of the applicant.
roleTitlestringThe title of the volunteer role they applied for.
cancellationTokenCancellationTokenCancellation 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.