FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

ForEach (Liquid) does't work

Open michaelsync opened this issue 3 years ago • 1 comments

I have this code. This Name: {{Name }} works but not the for loop. What did I miss?

I am sending this from .NET core console app. (Not MVC, I don't need the layout file too)

var template = @"
                            Name: {{ Name }} <br/>

                            <!-- if array = [1,2,3,4,5,6] -->
                            {% for item in array limit:2 %}
                              {{ item }}
                            {% endfor %}

                            ";


            SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Host = smtpServer;
            client.Port = 25;


            FluentEmail.Core.Email.DefaultSender = new SmtpSender(client);
            var options = new LiquidRendererOptions
            {};
            FluentEmail.Core.Email.DefaultRenderer = new LiquidRenderer(Options.Create(options));

            await FluentEmail.Core.Email
                .From(sender)
                .To(reportingEmail)
                .Subject(subject)
                .UsingTemplate(template, model)
                .SendAsync();

michaelsync avatar Nov 20 '21 07:11 michaelsync