Hi,
the html text area is a part where users can inserts their own html body and then send the email?
Or the imail is send based on template you have created?
To send an emial from html text area you could use the following code:
// Prepare the e-mail message
MailMessage msg = new MailMessage();
msg.From = new MailAddress(txtFrom.Text);
// Recipients
string[] to = txtTo.Text.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in to)
{
msg.To.Add(new MailAddress(s));
}
// Subject
msg.Subject = TextHelper.LimitLength(txtSubject.Text.Trim(), 450);
msg.Body = txtText.Text;
msg.IsBodyHtml = true;
In case you would like to send an email based on template text, please take a look at below example. There you can use
SendEmailWithTemplateText method:
EmailMessage msg = new CMS.EmailEngine.EmailMessage();
EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("templateCodeName", 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;
msg.Recipients = "user@domain.com";
msg.Subject = eti.TemplateSubject;
EmailSender.SendEmailWithTemplateText(CMSContext.CurrentSiteName, msg, eti, mcr, true );
Best regards,
Ivana Tomanickova