getAttachment (NotesDocument - JavaScript™)
Returns a representation of a file attachment.
Defined in
NotesDocumentSyntax
getAttachment(filename:string) : NotesEmbeddedObject
Parameter | Description |
---|---|
filename |
The file name of the file attachment. |
Return value | Description |
---|---|
NotesEmbeddedObject |
A representation of the file attachment. Returns null if an attachment by the specified name is not found. |
Usage
You can use this method to find file attachments that are not contained in a rich text item (such as an attachment in a Release 2 database) as well as file attachments that are contained in a rich text item.The Parent property
for the returned NotesEmbeddedObject
returns null,
since it was not accessed through a NotesRichTextItem
.
Examples
This button searches the documents in the current database for a specified attachment.try {
var dc:NotesDocumentCollection = database.getAllDocuments();
var doc:NotesDocument = NotesDocument = dc.getFirstDocument();
while (doc != null) {
var obj:NotesEmbeddedObject = doc.getAttachment(requestScope.query);
if (obj != null) {
requestScope.status = "Found " + obj.getName() + " in \"" +
doc.getItemValueString("Subject") + "\"";
break;
}
var tmpdoc = dc.getNextDocument();
doc.recycle(); // recycle to avoid memory problems
doc = tmpdoc;
}
if (!requestScope.status.startsWith("Found")) {
requestScope.status += "\nDid not find attachment"
}
} catch(e) {
requestScope.status = e.toString();
}