0

How do I populate IUrlHelper from a Background Quartz Task for Email Confirmation?

I am using Radzen Studio to create a custom website. It has automatically generated code for an Account Management Controller (AccountController.cs).

I would prefer to call the "SendConfirmationEmail" method from the Background Task (Quartz) to send the Client an Email when their account is created (within the Background Task).

I have not been able to find a good solution for populating the parameter "IUrlHelper url". Here's a copy of the SendConfirmationEmail Method:

public async Task SendConfirmationEmail(UserManager<ApplicationUser> userManager, ApplicationUser user, IUrlHelper url, string scheme)
{
    var code = await userManager.GenerateEmailConfirmationTokenAsync(user);
    var callbackUrl = url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: scheme);
    //
    // Author:  Richard
    // Date:    09/27/2022
    // Reason:  To import an EmailTemplate for Portal Invitation
    // 
    var EmailTemplate = portalDbService.GetEmailTemplateByAppLink("PortalInvite");
    string Body = EmailTemplate.Result.Body;
    string EmailBody = Body.Replace("{CLIENTNAME}", user.Email);
    string EmailSubject = EmailTemplate.Result.Subject;
    await SendEmail(user, code, callbackUrl, EmailSubject, EmailBody, true);
}

Thanks in Advance,
Richard

0 Answers0