[英]Lotus Notes - Mail Document - Get Attachment Names (and Export Attachments)
[英]getting the filenames of attachments in a Notes document
在Java中獲取Notes文檔中附件文件名的最簡單方法是什么?
就我而言,該文檔始終最多包含1個文件,並存儲在稱為“正文”的富文本字段中。
在您自己的java類中嘗試一下,它應該可以工作:
import com.ibm.xsp.model.domino.DominoUtils;
@SuppressWarnings("unchecked")
public List<String> getAttachmentsNames(RichTextItem richTextItem) {
List<String> attachmentsNames = new ArrayList<String>();
try {
Vector v = richTextItem.getEmbeddedObjects();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
EmbeddedObject eo = (EmbeddedObject) e.nextElement();
if (eo.getType() == EmbeddedObject.EMBED_ATTACHMENT) attachmentsNames.add(eo.getName());
}
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return attachmentsNames;
}
@SuppressWarnings("unchecked")
public List<String> getFileNames(Document document, String richTextFieldName) {
List<String> fileNames = new ArrayList<String>();
try {
if (document.hasEmbedded()) {
Vector<String> docFileNames = DominoUtils.getCurrentSession().evaluate("@AttachmentNames" , document);
RichTextItem rtitem = (RichTextItem) document.getFirstItem(richTextFieldName); // Body
for (int i = 0; i < docFileNames.size(); i++) {
if (!docFileNames.get(i).equals("") && getAttachmentsNames(rtitem).contains(docFileNames.get(i))) {
fileNames.add(fileNames.get(i));
}
}
}
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fileNames;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.