首页 > 解决方案 > 使用列表在 Kentico 电子邮件模板中的宏

问题描述

我有一个名为 Notifications 的类对象列表

 public class Notifications
    { 
        public string Name { get; set; }  
    }

有一个函数只返回通知列表。我想构建一个电子邮件模板,在 Kentico 中使用宏显示所有通知信息,不幸的是,当我使用宏方法时,例如

{%

foreach (var Data in Notification) {
 Data.Name
} 

#%} 

即使我确保所有数据都已成功发送到电子邮件,这样的宏根本不会返回输出,我想使用 foreach 循环。

标签: c#macroskenticoemail-templates

解决方案


我想通了,我们必须继承

AbstractDataContainer<ClassName>

并注册我们正在使用的字段

public class Notifications: AbstractDataContainer<Notifications>
    {   [RegisterColumn]
        public string Name { get; set; }  
    }

因此我们可以在 foreach 循环中使用 List


推荐阅读