FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Capturing the rendered email body

Open jovball opened this issue 3 years ago • 1 comments

I have a business case for capturing the rendered email body. Is that possible with FluentEmail? I am using Razor templates if that makes any difference.

jovball avatar Aug 30 '22 15:08 jovball

You can create a decorator for the mail sender and check the content there.

/// <summary>
/// Decorator for <c>FluentEmail.Core.Interfaces.ISender</c>.
/// </summary>
public class CustomMailSender : ISender
{
    ...
}

I use Autofac to register the decorator. builder.RegisterDecorator<CustomMailSender, ISender>();

This is independent of the type of mail sender you are actually using (smtp, sendgrid...).

For more info, I would suggest stackoverflow or discussions here.

DavidDeSloovere avatar Sep 09 '22 08:09 DavidDeSloovere