Episerver forms extended ... HTML placeholder

Vote:
 

Hi All,

I've extended Episerver forms to create an element that displays a summernote html wysiwyg area that allows the users to enter rich text.

This works fine, however when I attach a "Send email after form submission" and use a place holder say: "#HTMLTEXT#" 

When the email is created the Html text gets encoded as plain text. ie

...
I need to do the equivalent of @Html.Raw(#HTMLTEXT#) to include the text as HTML in the email

Any ideas on how this could be done?

Many thanks,

Paul  

#187841
Feb 05, 2018 2:26
Vote:
 

Did you ever get this sorted out? I'm having the same problem with html input being displayed as text instead of html in the email. Thanks!

#281391
Jun 05, 2022 6:46
Vote:
 

Hi Paul

If I don't misunderstand your question, you want to decode the #HTMLTEXT# value. The easiest way you can do is to create your custom SendEmailAfterSubmissionActor by inheriting from SendEmailAfterSubmissionActor, override "RewriteUrls" method to decode content. This method seems the last one gets called before set to mail body property.  (Don't forget to swap the SendEmailAfterSubmissionActor with your own one :))

#281431
Jun 06, 2022 6:09
Vote:
 

Thanks for the suggestion!

After digging through the code I ended up adding a custom PlaceHolderProvider that sets performHtmlEncode to false if the current placeholder name contains the string "html". That way I can mix between encoded and non encoded placeholders.

Some code if anyone stumbles on the same issue in the future:

		public new IEnumerable<PlaceHolder> ProcessPlaceHolders(IEnumerable<PlaceHolder> availablePlaceHolders, FormIdentity formIden, HttpRequestBase requestBase, Submission submissionData, bool performHtmlEncode)
		{
			IEnumerable<FriendlyNameInfo> friendlyNameInfos = this._formRepository.Service.GetFriendlyNameInfos(formIden);

			foreach (PlaceHolder availablePlaceHolder in availablePlaceHolders)
			{
				PlaceHolder ph = availablePlaceHolder;
				if (string.IsNullOrEmpty(ph.Value))
				{
					FriendlyNameInfo friendlyName = friendlyNameInfos.FirstOrDefault<FriendlyNameInfo>((Func<FriendlyNameInfo, bool>)(fn => fn.FriendlyName == ph.Key));
					if (friendlyName != null){
						performHtmlEncode = !friendlyName.FriendlyName.ToLower().Contains("html");
						ph.Value = this._formDataRepository.Service.GetSubmissionDataFieldValue(requestBase, submissionData, friendlyName, performHtmlEncode);
					}
				}
			}

			return availablePlaceHolders;
		}
#281446
Jun 06, 2022 20:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.