Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Compilation;
//using NewsletterStudio.Model;
using NewsletterStudio.Bll;
using NewsletterStudio.Core.Model;
namespace NewsletterStudio.Services.RenderTasks.Tasks
public class InsertCustomDataRenderTask : RenderTask
private EmailTrackingItem _trackingItem;
public override void ProcessPreRender(RenderResult renderResult, RenderTaskParameters parameters)
public override void ProcessUniqueItem(RenderResult renderResult, RenderTaskUniqueItemParameters parameters)
// If no custom data is includded, lets just ignore this.
if (!ConfigManager.NewsletterStudio.ActivateCustomDataCollection)
_trackingItem = parameters.EmailTrackingItem;
Regex regex = new Regex(@"\[#([^]]*)\]");
renderResult.MessageBody = regex.Replace(renderResult.MessageBody, GetCustomData);
private string GetCustomData(Match match)
string collectionKey = match.Groups[1].Value;
if (_trackingItem.Data.ContainsKey(collectionKey))
return _trackingItem.Data[collectionKey].ToString();
return string.Empty;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.