I have a .NET 7 project and I am trying to implement FluentEmail with Razor Templates so I can send emails to users for various different reasons. However I keep hitting Parameter count mismatch
which i think is coming from .UseTemplateFromFile()
It is configured in Startup.cs as so
services.AddFluentEmail("[email protected]")
.AddRazorRenderer()
.AddSmtpSender(smtpsettings["Server"], Convert.ToInt32(smtpsettings["Port"]), smtpsettings["Username"], smtpsettings["Password"]);
And in the controller where I am trying to send my email, the code looks like this. The namespace of the project is RackEmApp and the view lives in /Views/EmailTemplates
var path = Directory.GetCurrentDirectory();
var email = FluentEmail.Core.Email
.From("[email protected]")
.To(sendto)
.Subject(subject)
.UsingTemplateFromFile(Directory.GetCurrentDirectory() + "/Views/EmailTemplates/NewUserAdminNotification.cshtml", mergefields);
However, when I try and execute it, I get the response TargetParameterCountException: Parameter count mismatch.