Search code examples
javalotus-noteslotus-dominolotus

Embedding an attachment from a stream


Currently we are attaching a file to a Lotus Document with the following code:

final RichTextItem rtitem = document.createRichTextItem(referenceName);

final int type = EmbeddedObject.EMBED_ATTACHMENT;
final String clazz = null;
final String source = file.getFileName();
rtitem.embedObject(type, clazz, source, name);

document.save();

Unfortunately the source parameter of the embedObject method has to be a path of a file in the file system. Is it possible to embed an object from a stream somehow? The embeddable content currently is in the memory, so it's not too efficient (and clean) to write it out to a file and let the Lotus API to read it again.


Solution

  • The rtitem class only can attach files, not streams. However you can use MIME and the Lotus MimeEntry classes to create an attachment from anything that you can read. This LotusScript code sample should give you all you need to get started. The API is the same for Java. Let us know how it works for you.