The Domino server API getEmbeddedObjects();
returns the wrong result (zero) when a mail containing an attachment (as embedded object) is sent from the script.
Though an attachment is sent as an EmbeddedOBject
, getEmbeddedObjects();
returns ZERO
.
The mail type is NOT MIME
.
This is a Java application. Is there is any workaround for this problem?
I take the body from the document. If the body is of richtextitem, I call the getEmbeddedObjects() which returns zero though an attachment is present as embedded object.
Looking through all of the items in a document for the possibility of an attachment is doing a lot of work for nothing. All you need to do is get the collection of attachment names using the @AttachmentNames formula (available through the evaluate() method of the Session object, using the Document argument), and if the collection contains more than an empty string, use the getAttachment() method of the document to get a handle to the corresponding EmbeddedObject.
getAttachment() can grab any attachment to a document, whether it's associated with a RichTextItem or a V2-style attachment (as would be created by a web UI or when converting external mail). And never be afraid to use Formula Language when it's appropriate -- it can make your life a whole lot simpler.
If you get the embedded objects from the
Document
object, they won't contain attachments. UsinggetEmbeddedObjects
with the "Body"RichTextItem
gets the attachments too.Does that help?
Lotus Notes does not provide a single reliable method for extracting attachments from a NotesDocument object, unfortunately. To be thorough, you'll need to check through all richtext items it contains, as well as the document object itself.
I wrote the following code to extract attachments from selected emails in a mailbox, in an effort to cut down the file size (my users saved everything). The main loop is relevant to your question, though. It shows the process of looping through all of the document's items looking for richtext items with attachments, followed by a loop through all items again looking for items of type "Attachment".
(forgive the hackiness of the code. It wasn't written for efficiency)
Attachments do not necessarily have to be embedded inside a RichText field. To quote from the designer-help:
Another source of your problem could be, that there are several "Body" RichText items you would have to check.
HTH