Hello,
I am using E-Mail template for sending email.
I am using below code which is working fine when i pass recipientEmail="testvvv@gmail.com" (mens only one receipient):
see the below code:
private void SendEmailUsingTemplate(string emailTemplateName, string recipientEmail, string[,] replacements, string eventName)
{
// Set resolver
ContextResolver resolver = CMSContext.CurrentResolver;
resolver.SourceParameters = replacements;
// Get the email template
var template = EmailTemplateProvider.GetEmailTemplate(emailTemplateName, CMSContext.CurrentSiteID);
if (template != null)
{
// Email message
var emailMessage = new EmailMessage
{
EmailFormat = EmailFormatEnum.PlainText,
Recipients = recipientEmail,
From = "name@domain.com",
CcRecipients = template.TemplateCc,
BccRecipients = template.TemplateBcc,
Subject = resolver.ResolveMacros(template.TemplateSubject),
PlainTextBody = resolver.ResolveMacros(template.TemplatePlainText)
};
// Enable macro encoding for body
resolver.EncodeResolvedValues = true;
emailMessage.Body = template.TemplatePlainText;
// Disable macro encoding for plaintext body and subject
resolver.EncodeResolvedValues = false;
try
{
MetaFileInfoProvider.ResolveMetaFileImages(emailMessage, template.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE);
// Send the e-mail immediately
EmailSender.SendEmail(CMSContext.CurrentSiteName, emailMessage, true);
}
catch (Exception ex)
{
}
}
}
but now i want to add 2 recipients [
not cc or Bcc] say for Example:
1. testvvv@gmail.com
2. testppp@gmail.com
Can you please help me how i can add two recipients in "To" in Email not in cc or bcc.
Thank You.