I’m trying to remove the body text portion of an email’s ‘Body’ field but only leave the file attachments. I’ve had a lot of trouble getting this to work and don’t see anything in the forums.
In my first attempt I created this on each of the types
case RichTextItem.RTELEMxxxx: {
rtrange.setBegin(rtnav); rtrange.setEnd(rtnav);
System.out.println("Text run: " + rtrange.getTextRun());
System.out.println("removing element type " + elemTypeStr); rtrange.remove(); break;
}
however even when I called it on RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH,RichTextItem.RTELEM_TYPE_TEXTRUN,RichTextItem.RTELEM_TYPE_OLE,RichTextItem.RTELEM_TYPE_DOCLINK,RichTextItem.RTELEM_TYPE_SECTION,RichTextItem.RTELEM_TYPE_TABLE, and RichTextItem.RTELEM_TYPE_TABLECELL it would still leave text paragraphs and/or text runs in the document.
I took another approach and set the navigator just before the first attachment and did a .remove on the range. But because I dont know if the attachment has text paragraphs or text runs associated with it, I dont know where to begin the .remove after the attachment.
Has anybody been able to do this or have any better ideas ? I could detach the file attachment, call .remove on the whole RichTextItem, and then re-attach it but I keep thinking there has got to be a better way.
Subject: removing everything but attachments from RichTextItem
I would go with using NotesRichTextItem.EmbeddedObjects to loop through, get all the attachments, and move them to a new rich text item. Then just delete the original rich text item.
Subject: RE: removing everything but attachments from RichTextItem
I’m sorry if this is a novice question but I’ve looked all over. I have the EmbeddedObject from the RichTextItem field by using Vector v = body.getEmbeddedObjects();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
EmbeddedObject eo = (EmbeddedObject) e.nextElement();
But I cannot find a method other than embedObject to copy this to the new rich text item I created. It looks like embedObject goes to the filesystem which is why in my previous question I assumed it need to be detached first. How can I get ‘eo’ above into my new rich text item ?
Subject: RE: removing everything but attachments from RichTextItem
I’m sorry, that looks like Java, not LotusScript. Your initial post seemed to indicate you were using LotusScript. Which language are you looking to do this in?