在gmail API获取消息中,如何防止在获取当前消息时获取先前的消息链?

问题描述

我正在使用gmail api来获取最新消息。不幸的是,在获取消息时,它还将以前的消息链链接底部。我想防止或消除这种情况。有办法吗?

Message message = service.users().messages().get(user,messageId).setFormat("raw").execute();
getAttachments(service,user,messageId);
Base64 base64Url = new Base64(true);
byte[] emailBytes = base64Url.decodeBase64(message.getRaw());

Properties props = new Properties();
Session session = Session.getDefaultInstance(props,null);

MimeMessage email = new MimeMessage(session,new ByteArrayInputStream(emailBytes));

MimeMessageParser parser = new MimeMessageParser(email); //org.apache.commons.mail.util
parser.parse();
String content = parser.getHtmlContent();

预期:

enter image description here

获取

enter image description here

我们如何删除您在上面看到的该链?
api是否只能返回当前消息而不返回整个链?

我发现的一个解决方案是,我们可以从解析的数据中删除名称 gmail_quote 的div,但这似乎不是理想的解决方案。

<div dir="auto">Current Content<div dir="auto"><br></div></div><br>

<!--  
Below html content can be removed to hide chain
--> 
<div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed,26 Aug 2020,10:26 pm Ranju Machhi,&lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">PrevIoUs Content</div><div dir="auto"><br></div><div dir="auto"><br></div>
</blockquote></div>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)