问题
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