sozsoft-platform/api/modules/Sozsoft.Sender/Mail/SozsoftBackgroundEmailSendingJob.cs
2026-10-17 21:51:10 +03:00

34 lines
985 B
C#

using Volo.Abp.BackgroundJobs;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
namespace Sozsoft.Sender.Mail;
public class SozsoftBackgroundEmailSendingJob :
AsyncBackgroundJob<SozsoftBackgroundEmailSendingJobArgs>, ITransientDependency
{
protected ISozsoftEmailSender EmailSender { get; }
protected ICurrentTenant CurrentTenant { get; }
public SozsoftBackgroundEmailSendingJob(
ISozsoftEmailSender emailSender,
ICurrentTenant currentTenant)
{
EmailSender = emailSender;
CurrentTenant = currentTenant;
}
public override async Task ExecuteAsync(SozsoftBackgroundEmailSendingJobArgs args)
{
using (CurrentTenant.Change(args.TenantId))
{
await EmailSender.SendEmailAsync(
args.To,
args.Sender,
args.Params,
args.TextContent,
args.Subject,
args.Attachments);
}
}
}