Harmonickey / Serilog.Sinks.SendGridEmail

Sends the email notification through SendGrid
MIT License
2 stars 3 forks source link

EmailConnectionInfo.IsBodyHtml is not being respected #5

Open lazarus-cm opened 3 days ago

lazarus-cm commented 3 days ago

Summary When EmailConnectionInfo.IsBodyHtml is set to false emails are still being sent as HTML rather than plain text.

Reproduce Create an EmailConnectionInfo object with IsBodyHtml set to false (default anyway) Use the connection info when calling the Serilog WriteTo method

Expected outcome Email sent as plain text, not HTML.

Platform .Net 8 (windows) azure hosted web app


_connection = new EmailConnectionInfo
{
    EmailSubject = $"DC log event {Version}",
    FromEmail = _emailSettings.FromAddress,
    SendGridClient = new SendGridClient(_emailSettings.SendGridApiKey),
    ToEmail = string.Join(";", _emailSettings.SupportEmailAddresses),
    IsBodyHtml = false
};

config.WriteTo.Logger(x => x.Filter.ByIncludingOnly(Matching.WithProperty(Infrastructure.EmailOnlyNotification))
      .WriteTo.Email(_connection, batchPostingLimit: _emailSettings.AllowBatching ? 1000 : 1));
Harmonickey commented 3 days ago

Hey - your request is certainly reasonable. Just in case though, I submitted the change as a Major bump.

Give it some time, as the latest 3.0.0 version was just published. https://www.nuget.org/packages/Serilog.Sinks.SendGridEmail/

Then please give it a shot