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.
37 lines
924 B
37 lines
924 B
2 years ago
|
using System;
|
||
|
using Volo.Abp.BackgroundJobs;
|
||
|
using Volo.Abp.DependencyInjection;
|
||
|
using Volo.Abp.MailKit;
|
||
|
|
||
|
namespace Win_in.Sfs.Message.Application;
|
||
|
|
||
|
public class EmailSendingJob : BackgroundJob<EmailSendingArgs>, ITransientDependency
|
||
|
{
|
||
|
private readonly IMailKitSmtpEmailSender _emailSender;
|
||
|
public EmailSendingJob(IMailKitSmtpEmailSender emailSender)
|
||
|
{
|
||
|
_emailSender = emailSender;
|
||
|
}
|
||
|
|
||
|
public override void Execute(EmailSendingArgs args)
|
||
|
{
|
||
|
Action action = async () =>
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
await _emailSender.QueueAsync(
|
||
|
args.EmailAddress,
|
||
|
args.Subject,
|
||
|
args.Body,
|
||
|
true
|
||
|
).ConfigureAwait(false);
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Console.Write(e.Message);
|
||
|
}
|
||
|
};
|
||
|
action?.Invoke();
|
||
|
}
|
||
|
}
|