Example scripts
You can view some example scripts for creating a RichTextItem and extracting attachment from a RichTextItem.
Creating a RichTextItem
var rti = NotesConnectorName.connector.getDominoSession().getDatabase("", <database_name>)
.createDocument().createRichTextItem("Body");
var header = NotesConnectorName.connector.getDominoSession().createRichTextStyle();
header.setBold(lotus.domino.RichTextStyle.YES);
header.setColor(lotus.domino.RichTextStyle.COLOR_YELLOW);
header.setEffects(lotus.domino.RichTextStyle.EFFECTS_SHADOW);
header.setFont(lotus.domino.RichTextStyle.FONT_ROMAN);
header.setFontSize(14);
rti.appendStyle(header);
rti.appendText("Sample text which will be formatted with the above style.");
work.setAttribute("Body", rti);
Extracting attachment from a RichTextItem
var doc = NotesConnectorName.connector.getDominoSession().getDatabase("", <database_name>)
.getAllDocuments().getFirstDocument();
if (doc.hasEmbedded()) {
var body = doc.getFirstItem("Body");
var rtnav = body.createNavigator();
if (rtnav.findFirstElement(
lotus.domino.RichTextItem.RTELEM_TYPE_FILEATTACHMENT)) {
do {
var att = rtnav.getElement();
var path = "c:\\Files\\" + att.getSource();
att.extractFile(path);
main.logmsg(path + " extracted");
} while (rtnav.findNextElement());
}
else
main.logmsg ("No attachments");
}
else
main.logmsg ("No attachments or embedded objects");
For more information and examples see the Domino® documentation at: http://www-128.ibm.com/developerworks/lotus/documentation/dominodesigner/