Hi I am using the Gmail API to grab a message and extract its body content. I can successfully do that and am able to decode it to text. I've provided the code below. However, the issue I'm running into is the text that is decoded occasionally comes with a bulk of CSS code that I don't want.
Is there a way to get rid of any HTML and CSS code that may come in the decoded text? Thanks
gapi.client.gmail.users.messages.get({
'userId': userId,
'id': message.id
}).then(function(response) {
var payload = response.result.payload;
var Body_obj = (payload.parts) ? payload.parts[0].body.data : payload.body.data;
console.log( atob(Body_obj.replace(/-/g, '+').replace(/_/g, '/')) );
Here's an example of all the CSS junk I get with the decoded message text:
p{ margin:10px 0; padding:0; } table{ border-collapse:collapse; } h1,h2,h3,h4,h5,h6{ display:block; margin:0; padding:0; } img,a img{ border:0; height:auto; outline:none; text-decoration:none; } body,#bodyTable,#bodyCell{ height:100%; margin:0; padding:0; width:100%; } .hrdPreviewText{ display:none !important; } (so much CSS I do not want...) .hrdTextContent li{ font-size:14px !important; line-height:150% !important; } }
Now some real text I want.