Sep 20, 2011 7:36 AM
66 Posts

Problem with body field data type in email - richtext versus mime type ...

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 3
In xPages app, I have to manipulate with mail message using the Java code.  For certain mail messages I cant access the body field as richtext. I'm using standard
 
 RichTextItem rt = (RichTextItem) doc.getFirstItem("body"); 
 
For certain internet messages I'm getting error:   java.lang.ClassCastException: lotus.domino.local.Item incompatible with lotus.domino.RichTextItem
It's because the body field (I can see it in document properties)  is type mime: 'Data Type: MIME Part' and not richtext . How can I handle this? I need to access field as RichText because I need to append this body field at the and of another rich text item using "appendRTItem" method.
 
Anyone any idea? Please ... 
 
Sep 20, 2011 9:29 AM
6 Posts
Re: Problem with body field data type in email - richtext versus mime type ...
have a read of the domino help on MimeEntity Class, I think the getContentAsText method is what you are looking for.
Sep 20, 2011 9:46 AM
66 Posts
Re: Problem with body field data type in email - richtext versus mime type ...
 Thank you, I tried this already, but this method return only following general text: "This is a multi-part message in MIME format" ... but not the content itself.
Sep 20, 2011 12:17 PM
6 Posts
Re: Problem with body field data type in email - richtext versus mime type ...
Ok I have never done this before, however what I do know is: getContextAsText is only good with MIMEEntity when that Mime Entity header content-type and content subtype (use getContentType() and getContentSubType() ) is either "text/plain " or "text/html". Of course if it is text/html, getContextAsText will return all the content with the html tags... Note that MimeEntity could be a child MimeEntity to the MimeEntity you first get from the doc.getMimeEntity() If the top MimeEntity Content Type is not "multipart" then you could just use getContextAsText on the top MimeEntity to get all the content, then write that text to your other Body Item. Do let us know if this somehow worked.