How to seperate email body from a rendered thread through IMAP?

183 Views Asked by At

I am fetching emails using IMAP but when we render a particular message body along with it fetches all replies/conversation along with it. I want to separate those messages and also want to separate a particular message body with a signature as well.

what I received right now

enter image description hereenter image description here

What I want to achieve

enter image description hereenter image description here

HTML body for first mail i.e. receieved mail

"<div style=\"padding-bottom: 20px;\"></div><div><html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title></title>\n</head>\n<body>\n<div dir=\"ltr\">\n<div>Hey Bhavin,<br />\n<br /></div>\nThis is LA TEST 01 to test threads for Letter<br clear=\"all\" />\n<div>\n<div><br />\n--<br />\n<div dir=\"ltr\" class=\"gmail_signature\" data-smartmail=\n\"gmail_signature\">\n<div dir=\"ltr\">\n<div>\n<div dir=\"ltr\">----------<br />\n<span style=\"font-family:georgia,serif\"><font size=\"2\">Thanks &amp;\nRegards</font><br /></span></div>\n<div>Stack<br /></div>\n<div dir=\"ltr\"><span style=\"font-family:georgia,serif\"><font size=\n\"2\"><i><br /></i></font></span></div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>\n</div>"

HTML body for second mail i.e. reply

"<div style=\"padding-bottom: 20px;\"></div><div><html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title></title>\n</head>\n<body>\n<div class=\"ydp462b3c77yahoo-style-wrap\" style=\n\"font-family: verdana, helvetica, sans-serif; font-size: 13px;\">\n<div>\n<div dir=\"ltr\" data-setdir=\"false\">Hi Stack,<br />\n<br />\nThanks for the info. Let me do the test for LA TEST 01 from my side\nas well.<br /></div>\n<div><br /></div>\n<div class=\"ydp462b3c77signature\">\n<div style=\n\"font-family:verdana, helvetica, sans-serif;font-size:13px;\">\n--<br />\n<div><font size=\"2\">Thanks &amp; Regards</font></div>\n<div><b>Bhavin Bhadani</b></div>\n<div id=\"ydp267338c6yui_3_16_0_ym19_1_1469425690897_2386\">\n<font size=\"2\"><i>iOS Developer&nbsp;</i></font><font face=\n\"Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif\"><br />\n</font></div>\n<div><font size=\"2\"><i><b>skype:</b>\nbhavi</i></font></div>\n</div>\n</div>\n</div>\n<div><br /></div>\n<div><br /></div>\n</div>\n<div id=\"yahoo_quoted_4513314037\" class=\"yahoo_quoted\">\n<div style=\n\"font-family:\'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;\">\n<div>On Wednesday, 23 June, 2021, 12:09:22 pm IST, Stack Help\n&lt;[email protected]&gt; wrote:</div>\n<div><br /></div>\n<div><br /></div>\n<div>\n<div id=\"yiv6922098475\">\n<div dir=\"ltr\">\n<div>Hey Bhavin,<br />\n<br /></div>\nThis is LA TEST 01 to test threads for Letter<br clear=\"all\" />\n<div>\n<div><br />\n--<br />\n<div dir=\"ltr\" class=\"yiv6922098475gmail_signature\">\n<div dir=\"ltr\">\n<div>\n<div dir=\"ltr\">----------<br />\n<span style=\"font-family:georgia, serif;\"><font style=\n\"background-color: inherit;\" size=\"2\">Thanks &amp;\nRegards</font><br /></span></div>\n<div>Stack<br /></div>\n<div dir=\"ltr\"><span style=\n\"font-family:georgia, serif;\"><font style=\n\"background-color: inherit;\" size=\n\"2\"><i><br /></i></font></span></div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</div>\n</body>\n</html>\n</div>"

I am using MailCore 2 for iOS and JavaMail for Android.

0

There are 0 best solutions below