ASPX templates
Version 6.x > ASPX templates > About Multiple Recipients in Email Template. View modes: 
User avatar
Member
Member
ankit_p_mistry_123-yahoo.co - 1/15/2013 4:53:13 AM
   
About Multiple Recipients in Email Template.
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.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/16/2013 5:59:57 AM
   
RE:About Multiple Recipients in Email Template.
Hi,

Have you tried using the semicolon (;) to separate multiple recipients in the TO setting?

Best regards,
Juraj Ondrus

User avatar
Member
Member
ankit_p_mistry_123-yahoo.co - 1/16/2013 7:40:06 AM
   
RE:About Multiple Recipients in Email Template.
Thank You for your Response.

Yes i have tried by putting semicolon (;) but at this time it is not firing the email.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/17/2013 2:08:36 AM
   
RE:About Multiple Recipients in Email Template.
Hi,

What was the exact value you have entered? I just tested it and it is working just fine - there should not be any space behind the semicolon.

Best regards,
Juraj Ondrus

User avatar
Member
Member
ankit_p_mistry_123-yahoo.co - 1/17/2013 10:25:36 PM
   
RE:About Multiple Recipients in Email Template.
Thank you Very Much.

It is working Fine.