更新EmailMessage后,邮件正文发生更改 [英] Message body changes after updating EmailMessage
问题描述
我的目标是加载电子邮件,如果是新邮件,则将其标记为已读.
My target is to load an email message and if it's a new one mark it as read.
这就是我在做什么:
EmailMessage email=EmailMessage.bind(service,itemId);
email.load();
email.setSubject(GeneralUtils.replaceSpecialCharacters(email.getSubject()));
email.setBody(MessageBody.getMessageBodyFromText(GeneralUtils.replaceSpecialCharacters(email.getBody().toString())));
if(!email.getIsRead()){
email.setIsRead(true);
email.update(ConflictResolutionMode.AutoResolve);
}
问题:第一次读取消息正文时(在将消息标记为已读之前) 我可以正确读取邮件正文,如下所示:
ISSUE: When reading the message body for first time (before marking the message as read) I can read the message body correctly as follows:
This is message body
但是在将邮件标记为已读并更新邮件之后,当尝试再次加载此电子邮件时,邮件正文将按以下方式加载:
But after marking the message as read and update the message, when trying to load this email again, the message body loads as follows:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
This is message body
</body>
</html>
请告知为什么我会出现这种情况,以及如何解决此问题.
Please advise why I am getting this behavior, and how to solve it.
推荐答案
我通过不设置处理主体来解决它,我删除了以下行,并且工作正常:
I fixed it by not setting the processed body, i removed the following line, and it works fine:
email.setBody(MessageBody.getMessageBodyFromText(GeneralUtils.replaceSpecialCharacters(email.getBody().toString())));
这篇关于更新EmailMessage后,邮件正文发生更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!