Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29755

Render Html code from a property using FluentMail in C#

$
0
0

I am using the FluentMail for sending emails from template in .Net Core. There is a problem when using it, because one property is a string where I store HTML, the problem that instead of processing the HTML, it is printing it like

<p> this is a text </p> 

instead of

this is a text

The code is basically like:

var inviteEmailViewModel = new InviteEmailViewModel(_emailAppSettings.EmailInviteSubject,
               requester.Name,
               roleName,
               entityType,
               entityName,
               invitationUrl,
               registrationUrl,
               textPreview,
               text);

            var inviteEmailPath = $"{Directory.GetCurrentDirectory()}{_emailAppSettings.EmailInvitePath}";

            List<Address> adresses = emailsTo.Select(x => new Address() { EmailAddress = x }).ToList();

            var sendResponse = await _fluentEmail
               .To(adresses)
               .Subject(_emailAppSettings.EmailInviteSubject)
               .UsingTemplateFromFile(inviteEmailPath, inviteEmailViewModel)
               .SendAsync();

The InviteEmailViewModel has the string property Text

And the template is defined as below

<table>
    <tbody>
        <tr>
            <td>@Model.Text</td> 
        </tr>
    </tbody>
</table>

How can I render the HTML that is passed on the string, instead of printing it as a string?

I already tried something like @Html.Raw, but it throws an exception on FluentMail.


Viewing all articles
Browse latest Browse all 29755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>