Click here to Skip to main content
15,886,723 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

As part of my project, I can able to read the email using Gmail API but my problem is when I fetch the body, the signature is seen along with the body. So I need to remove the Gmail signature and fetch only the content or message of body.

is there is any other way to remove the Gmail signature (like regular expression ..)?

Please shed some light?

What I have tried:

I tried a lot, I use
MimeType == "text/html"
and get the formate in HTML and then find the class
//div[@class='gmail_signature']
using HTML document (using HtmlAgilityPack).

var nodes = htmlDoc.DocumentNode.SelectNodes("//div[@class='gmail_signature']").ToList();
                    if (nodes.Count > 0)
                    {
                        foreach (var item in nodes)
                        {
                            item.Remove();

                        }
                    }
var result = htmlDoc.DocumentNode.InnerText.Replace(System.Environment.NewLine, string.Empty);
                result = System.Web.HttpUtility.HtmlDecode(result);


But in some condition, the Gmail signature is coming.
Posted
Comments
F-ES Sitecore 17-Apr-19 6:14am    
Analysise the emails where the signature is still there to see why your code failed. It might be because those emails are plain text.
aravindnass 17-Apr-19 7:33am    
Thanks for your reply...But in some emails having like "Warm Regards" or "Thanks & Regards". How can I remove this?
ZurdoDev 22-Apr-19 15:55pm    
By writing a bunch of code to do it. If it isn't tagged as a signature, there's no way to know you want it removed, right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900