chamara
chamara

Reputation: 12709

Kentico Get Current Recipient contact info

I'm trying to get current email recipent data inside a custom macro field. My code below.

using CMS;
using CMS.DataEngine;
using CMS.MacroEngine;
using CMS.Membership;
//using CMSApp.CustomMethods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

// Registers the custom module into the system
[assembly: RegisterExtension(typeof(EmailContactMacroFields), typeof(CustomContact))]

public class EmailContactMacroFields : MacroFieldContainer
{
    protected override void RegisterFields()
    {
        base.RegisterFields();

        // Defines a custom macro field in the container
        RegisterField(new MacroField("TestField", () => UserInfo.Provider.Get("administrator")));
        
    }
}

Instead of using 'UserInfo.Provider.Get("administrator")' how do I get the current recipient? Something like 'ContactProvider.CurrentRecipient'

We are trying to use this new macro in our email templatest. Is this possible?

I know I can do this with a custom macro method just by passing the email as a parameter. However, there's no option to show the custom macro method in the macro tree view and hence we have to use a macro field.

Upvotes: 0

Views: 51

Answers (0)

Related Questions