Exemplo n.º 1
0
        public void SendFormEmail(BizFormItem item, int attachmentsCount)
        {
            if (item.BizFormInfo != null)
            {
                MacroResolver resolver = MacroContext.CurrentResolver.CreateChild();
                resolver.SetAnonymousSourceData(item);
                resolver.Settings.EncodeResolvedValues = true;
                resolver.Culture = CultureHelper.GetPreferredCulture();

                string body = DataHelper.GetNotEmpty(item.BizFormInfo.FormEmailTemplate, string.Empty);
                body = resolver.ResolveMacros(body);

                EmailMessage message = new EmailMessage();
                message.From        = item.BizFormInfo.FormSendFromEmail;
                message.Recipients  = resolver.ResolveMacros(item.BizFormInfo.FormSendToEmail);
                message.Subject     = resolver.ResolveMacros(item.BizFormInfo.FormEmailSubject);
                message.Body        = URLHelper.MakeLinksAbsolute(body);
                message.EmailFormat = EmailFormatEnum.Html;

                for (int i = 1; i <= attachmentsCount; i++)
                {
                    Attachment attachment = GetAttachment(item.GetStringValue("File" + i, string.Empty));
                    if (attachment != null)
                    {
                        message.Attachments.Add(attachment);
                    }
                }
                EmailSender.SendEmail(message);
            }
        }
        private void SendAcknowledgementEmail(BizFormInfo formInfo, BizFormItem item, IList <IControl> controls)
        {
            AddSpecialFormControls(formInfo, item, controls);

            EmailMessage em = new EmailMessage
            {
                EmailFormat = EmailFormatEnum.Html,
                From        = formInfo.FormConfirmationSendFromEmail,
                Recipients  = item.GetStringValue(formInfo.FormConfirmationEmailField, String.Empty),
                Subject     = formInfo.FormConfirmationEmailSubject,
                Body        = _emailParser.Parse(formInfo.FormConfirmationTemplate, controls)
            };

            EmailSender.SendEmail(em);
        }