You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.0 KiB
2.0 KiB
LINGYUN.Abp.Notifications.Emailing
The email sending module of the notification system, providing functionality to send notifications via email.
Features
- Email notification sending
- Email template support
- Support for HTML format emails
- Support for multiple recipients
- Support for CC and BCC
Module References
[DependsOn(typeof(AbpNotificationsEmailingModule))]
public class YouProjectModule : AbpModule
{
// other
}
Configuration
{
"Notifications": {
"Emailing": {
"Templates": {
"Default": {
"Template": "DefaultTemplate",
"Culture": "en"
}
}
}
}
}
Basic Usage
- Configure Email Settings
Configure<AbpEmailingOptions>(options =>
{
options.DefaultFromAddress = "noreply@example.com";
options.DefaultFromDisplayName = "Notification System";
});
- Send Email Notification
public class YourNotificationHandler : INotificationHandler
{
private readonly IEmailSender _emailSender;
public YourNotificationHandler(IEmailSender emailSender)
{
_emailSender = emailSender;
}
public async Task HandleAsync(NotificationInfo notification)
{
await _emailSender.SendAsync(
to: notification.UserEmail,
subject: notification.Title,
body: notification.Content,
isBodyHtml: true
);
}
}
- Use Email Template
public async Task SendWithTemplateAsync()
{
var template = await _templateRenderer.RenderAsync(
"DefaultTemplate",
new {
Title = "Notification Title",
Content = "Notification Content"
}
);
await _emailSender.SendAsync(
to: "user@example.com",
subject: "Notification",
body: template,
isBodyHtml: true
);
}