Hi I was wondering if there were any help guides or code samples we could use to help us build this solution. We've got a custom ad-hoc page which basically functions as a form with custom fields into which users can input info. Once the user gets to the end of the form, and click the Submit button, it validates the info, then dumps it into the specified Email Template in Kentico and shoots it out to the specified Recipients. But we would like the page to be able to also accommodate file uploads/attachments which also get sent to the Recipients using the E-mail Template in Kentico. Is there any easy way to do this or a code solution that would help achieve this type of functionality?Below is the code that generates the e-mail but not sure how to get a file to upload via the form or even how to get it to attach to the e-mail when it gets sent. Thank you in advance for any help you can offer: protected void createEmail(){
CMS.EmailEngine.EmailMessage em = new CMS.EmailEngine.EmailMessage();
em.EmailFormat = CMS.EmailEngine.EmailFormatEnum.Html;
CMS.EmailEngine.EmailTemplateInfo eti = CMS.EmailEngine.EmailTemplateProvider.GetEmailTemplate(@FormEmailTemplate@, CMS.SiteProvider.SiteContext.CurrentSiteID);
string activitiesInfo = getActivitiesInfo();
string awardsInfo = getAwardsInfo();
CMS.EmailEngine.EmailMessage emReturn = new CMS.EmailEngine.EmailMessage();
emReturn.EmailFormat = CMS.EmailEngine.EmailFormatEnum.Html;
CMS.EmailEngine.EmailTemplateInfo etiReturn = CMS.EmailEngine.EmailTemplateProvider.GetEmailTemplate(@formReminderTemplate@, CMS.SiteProvider.SiteContext.CurrentSiteID);
//string activitiesInfo = getActivitiesInfo();
//string awardsInfo = getAwardsInfo();
var mcr = CMS.MacroEngine.MacroResolver.GetInstance();
foreach (string key in Request.Form.AllKeys)
{
if (!isActivityOrAwardKey(key))
mcr.SetNamedSourceData(key, Request.Form[key]);
}
mcr.SetNamedSourceData(@activitiesInfo@, getActivitiesInfo());
mcr.SetNamedSourceData(@awardsInfo@, getAwardsInfo());
mcr.SetNamedSourceData(@formInfo@, getFormInfo());
em.EmailFormat = CMS.EmailEngine.EmailFormatEnum.Both;
em.From = Request.Form[@emailAddr@]; //make sure this is specified in the template settings
em.Recipients = @xxxxxxx@xxxxxxx.com;@; //Request.Form[@email@];
em.Subject = DocumentContext.CurrentTitle.ToString();
emReturn.EmailFormat = CMS.EmailEngine.EmailFormatEnum.Both;
emReturn.From = @info@xxxxxxx.com@; //Request.Form[@emailAddr@]; //make sure this is specified in the template settings
emReturn.Recipients = Request.Form[@emailAddr@]; //Request.Form[@email@];
emReturn.Subject = @CONFIRMED: Form Submitted@;//DocumentContext.CurrentTitle.ToString();
CMS.EmailEngine.EmailSender.SendEmailWithTemplateText(CMS.SiteProvider.SiteContext.CurrentSiteName, em, eti, mcr, true);
CMS.EmailEngine.EmailSender.SendEmailWithTemplateText(CMS.SiteProvider.SiteContext.CurrentSiteName, emReturn, etiReturn, mcr, true);
}
↧