Search code examples
javaexchangewebservices

How to get preview of the email body


I want to get the first 255 character of email body. Like in Outlook we have on our left panel we see list of emails displayed with one line of message body. I wanted to get preview of an email message.

Any inbuilt api from ews is good rather than doing string manipulation Can anyone please help me out. Thanks in advance


Solution

  • I'm not sure if I understand you correctly but in case you just want to get the first 255 characters of an existing string you can use:

    String message; //String that holds your message
    String previewMessage = ""; //String to store your pewview message
    
    if(message.length() >= 255) {
      previewMessage = message.substring(0, 254);
    }