cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Remove CSS from Body column in SharePoint 2013

I'm looking to send automatic email notifications when someone submits a file via email to a discussion list. I chose this list type because it allows us to capture an email's body text without any custom code or additional hassle. I've enabled the list to allow users to submit files in email as attachments.

 

The problem I'm running into is that a bunch of CSS comes embedded in the Body field, so when I get the email notification I have to wade through a bunch of irrelevant information just to get to the message. Here's some sample output:

 

B55C039C46B049E6B21E0D6DE226C908 .shape {

}

 

B55C039C46B049E6B21E0D6DE226C908 p.MsoNormal, B55C039C46B049E6B21E0D6DE226C908 li.MsoNormal, B55C039C46B049E6B21E0D6DE226C908 div.MsoNormal {

margin:0in;

margin-bottom:.0001pt;

font-size:11.0pt;

font-family:"Calibri","sans-serif";

}

 

[. . . lots more of this, then the actual message:]

 

The attached file contains super important information.

 

While this isn't a huge deal for me, I can't expect my users to know what to look for. Is there a way to strip out (or force rendering of) CSS? My initial idea is to use functions to find the last occurrence of a closing curly brace and remove everything from the body's beginning to that index. If this is a good way to approach it, I'm not sure how to actually accomplish it and would appreciate assistance. However, if there's a better approach, I'm happy to entertain it.

 

Thanks for your advice!

Labels: (1)
0 Kudos
Reply
1 Reply
Not applicable

Re: Remove CSS from Body column in SharePoint 2013

It turns out my original idea was the right start-- find the last occurrence and extract everything after it. I ended up accomplishing this with a regular expression action. The configuration in Workflows 2013 was this:

 

Pattern: [^}]+$

Operation: Extract

Input text: {ItemProperty:Body}

Store result in: collCleanedBody

 

Explanation: Pattern locates the final occurrence of a given character. In this case, I used the closing curly brace. The extract operation retrieves everything contained in the Input text field after the matching pattern, which leaves me with the actual message only. Finally, I store the result in a collection variable (the only type which the extract operation recognizes). Once stored, I can use this throughout the rest of the workflow simply by referencing the variable. Good to go!

0 Kudos
Accept as Solution Reply