I have an email template, and I send it via code to some users. Works great.
I want to add an attachment to the email template. So I want into the email template and clicked attach. I upload the PDF, and hit save. It now shows beneath the email template.
When I send the email from the code, there is no attachment.
private void SendEmail(UserInfo userInfo, string emailTemplateName)
{
EmailMessage msg = new CMS.EmailEngine.EmailMessage();
EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate(emailTemplateName, CMSContext.CurrentSiteID);
MacroResolver mcr = new MacroResolver();
mcr.SpecialMacros = new String[,] { { "#firstname#", userInfo.FirstName }, { "#lastname#", userInfo.LastName } };
msg.EmailFormat = EmailFormatEnum.Default;
msg.From = eti.TemplateFrom;
msg.Recipients = userInfo.Email;
msg.Body = CMSContext.CurrentResolver.ResolveMacros(msg.Body);
msg.Subject = eti.TemplateSubject;
EmailSender.SendEmailWithTemplateText(CMSContext.CurrentSiteName, msg, eti, mcr, true);
}
I see that there is EmailMessage.Attachments, but how can I set that field to the attachment from the template?
Thanks,
Joe