sozsoft-platform/api/modules/Sozsoft.Sender/Mail/SozsoftBackgroundEmailSendingJob.cs

35 lines
985 B
C#
Raw Normal View History

using Volo.Abp.BackgroundJobs;
2026-02-24 20:44:16 +00:00
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
2026-02-24 20:44:16 +00:00
namespace Sozsoft.Sender.Mail;
2026-10-17 18:51:10 +00:00
public class SozsoftBackgroundEmailSendingJob :
AsyncBackgroundJob<SozsoftBackgroundEmailSendingJobArgs>, ITransientDependency
2026-02-24 20:44:16 +00:00
{
protected ISozsoftEmailSender EmailSender { get; }
protected ICurrentTenant CurrentTenant { get; }
2026-02-24 20:44:16 +00:00
2026-10-17 18:51:10 +00:00
public SozsoftBackgroundEmailSendingJob(
ISozsoftEmailSender emailSender,
ICurrentTenant currentTenant)
2026-02-24 20:44:16 +00:00
{
EmailSender = emailSender;
CurrentTenant = currentTenant;
2026-02-24 20:44:16 +00:00
}
2026-10-17 18:51:10 +00:00
public override async Task ExecuteAsync(SozsoftBackgroundEmailSendingJobArgs args)
2026-02-24 20:44:16 +00:00
{
using (CurrentTenant.Change(args.TenantId))
{
await EmailSender.SendEmailAsync(
args.To,
args.Sender,
args.Params,
args.TextContent,
args.Subject,
args.Attachments);
}
2026-02-24 20:44:16 +00:00
}
}