Email validation failed

ssellmeyer
Tera Guru

How is this possible?

If the data input is having any HTML tags, the source field type should be HTML instead of string. If that is not possible, then there should be some intermediate step to encode it before passing to SendEmail action.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1124509

 

Can someone please explain in detail how this can be accomplished?

We are getting this error on a 'Send Email' action in a FD flow:

Email validation failed: Email body is comprised of invalid HTML.

1 ACCEPTED SOLUTION

Su522
Kilo Sage

Clean HTML- Flow Designer Action

Create a FD Action with Input:

Su522_0-1726248276076.png

 

Script Step:

Su522_1-1726248276078.png

 

Script:

(function execute(inputs, outputs) {  

 

// Input variable

  var htmlString = inputs.htmlString;

 

// Remove HTML tags using regular expressions

var cleanString = htmlString.replace(/<br ?\/?>|<\/p>/ig, "\n");

cleanString = cleanString.replace(/<script[^>]+>.*<\/script>/ig);

cleanString = cleanString.replace(/<style[^>]+>.*<\/style>/ig);

cleanString = cleanString.replace(/<[^>]+>/g, "");

 

// Output variable

outputs.text_out = cleanString;

 

})(inputs, outputs);

 

Su522_2-1726248276079.png

 

Create Action Output:

Su522_3-1726248276081.png

 

Su522_4-1726248276081.png

 

Call the FD Action from the FD Flow:

(this will get the latest email response)

Su522_5-1726248276083.png

View solution in original post

2 REPLIES 2

Su522
Kilo Sage

Any help on this?

Su522
Kilo Sage

Clean HTML- Flow Designer Action

Create a FD Action with Input:

Su522_0-1726248276076.png

 

Script Step:

Su522_1-1726248276078.png

 

Script:

(function execute(inputs, outputs) {  

 

// Input variable

  var htmlString = inputs.htmlString;

 

// Remove HTML tags using regular expressions

var cleanString = htmlString.replace(/<br ?\/?>|<\/p>/ig, "\n");

cleanString = cleanString.replace(/<script[^>]+>.*<\/script>/ig);

cleanString = cleanString.replace(/<style[^>]+>.*<\/style>/ig);

cleanString = cleanString.replace(/<[^>]+>/g, "");

 

// Output variable

outputs.text_out = cleanString;

 

})(inputs, outputs);

 

Su522_2-1726248276079.png

 

Create Action Output:

Su522_3-1726248276081.png

 

Su522_4-1726248276081.png

 

Call the FD Action from the FD Flow:

(this will get the latest email response)

Su522_5-1726248276083.png