I have an application that reads the email from exchange using EWS. My problem is that to get the TEXT version of the email, not HTML version. I've tried to use this codes below. The "emailBody" what I've got from Exchange Server is not the Text version. I want to get only text, not html tags. So please recommend any method to covert it.
public Map readEmailItem(ItemId itemId){
Map messageData = new HashMap();
try{
Item itm = Item.bind(service, itemId, pertySet.FirstClassProperties);
EmailMessage emailMessage = EmailMessage.bind(service, itm.getId());
messageData.put("emailItemId", emailMessage.getId().toString());
messageData.put("subject", emailMessage.getSubject().toString());
messageData.put("fromAddress",
emailMessage.getFrom().getAddress().toString());
messageData.put("senderName",
emailMessage.getSender().getName().toString());
Date dateTimeCreated = emailMessage.getDateTimeCreated();
messageData.put("SendDate",dateTimeCreated.toString());
Date dateTimeRecieved = emailMessage.getDateTimeReceived();
messageData.put("RecievedDate",dateTimeRecieved.toString());
messageData.put("Size",emailMessage.getSize()+"");
messageData.put("emailBody",emailMessage.getBody().toString());
}catch (Exception e) {
e.printStackTrace();
}
return messageData;
}
Aucun commentaire:
Enregistrer un commentaire