Message body changes after updating EmailMessage

坚强是说给别人听的谎言 提交于 2019-12-11 07:57:10

问题


My target is to load an email message and if it's a new one mark it as read.

So here is what I am doing:

        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.


回答1:


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())));


来源:https://stackoverflow.com/questions/13439926/message-body-changes-after-updating-emailmessage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!