Sending E-mails using API in Kentico 8

Raj koppola asked on September 22, 2014 22:37

I was trying to send the email in kentico 8 using the following code but it is throwing the following error. error CS1061: 'CMS.MacroEngine.MacroResolver' does not contain a definition for 'SpecialMacros'

EmailMessage msg = new CMS.EmailEngine.EmailMessage(); EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("EmailTemplateCodeName", CMSContext.CurrentSiteID);

 MacroResolver mcr = new MacroResolver();
 mcr.SpecialMacros = new String[,] { { "#macro#", "text" } }; //here you can specify text for multiple macros specified in template

 msg.EmailFormat = EmailFormatEnum.Both;
 msg.From = eti.TemplateFrom; //make sure this is specified in the template settings
 msg.Recipients = "";
 msg.Subject = eti.TemplateSubject;

 EmailSender.SendEmailWithTemplateText(CMSContext.CurrentSiteName, msg, eti, mcr, true);

Recent Answers

Yehuda Lando answered on September 22, 2014 23:14

You don't have that property any more. Instead you do it like this:

var resolver = MacroResolver.GetInstance();

where macros is your string array.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.