我正在尝试删除以前使用 MIME 添加的附件。这是我的代码
try{
var d = database.getView("Main").getFirstDocument()
var it = d.getFirstItem("Body")
var att:NotesEmbeddedObject = it.getEmbeddedObject("mydoc.docx")
var streamDOC:NotesStream = session.createStream()
streamDOC.setContents(att.getInputStream())
var newd;
newd = database.getView("NewD").getFirstDocument()
if(newd==null){
newd = database.createDocument()
newd.replaceItemValue("Form","Main")
var me = newd.createMIMEEntity("Body")
}else{
var me = newd.getMIMEEntity("Body")
}
var filename = "test.pdf"
var mc = me.createChildEntity();
var he = mc.createHeader("Content-Disposition")
he.setHeaderVal("attachment; filename=\"" + filename + "\"");
he = mc.createHeader("Content-ID");
he.setHeaderVal( "<" + filename + ">" );
mc.setContentFromBytes(streamDOC, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", NotesMIMEEntity.ENC_IDENTITY_8BIT);
newd.save()
print("success")
}catch(e){
print("fail " + e)
}
这是我用来删除附件的代码
<xp:repeat id="repeat1" rows="30"
value="#{javascript:@AttachmentNames()}" var="att"
>
<xp:text tagName="p" escape="true" id="computedField1"
value="#{javascript:att}"
>
</xp:text>
<xp:link escape="true" text="Delete" id="link2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete"
>
<xp:this.action><![CDATA[#{javascript:try{
var it:NotesRichTextItem = nd.getDocument().getFirstItem("Body")
var eo:NotesEmbeddedObject = it.getEmbeddedObject(att)
if(eo==null){
print("No attachment found")
}else{
print("att ok")
eo.remove()
nd.save()
}
print("success delete " + e)
}catch(e){
print("fail delete " + e)
}}]]></xp:this.action>
</xp:eventHandler></xp:link>
</xp:repeat>
在 ytria 我的文档看起来像这样
当我尝试使用链接删除附件时,出现以下错误
2018-11-22 10:27:48 HTTP JVM:失败删除错误在“lotus.domino.local.Item”类型的对象上调用方法“getEmbeddedObject(字符串)”[静态 Java 接口包装器,lotus.domino.local.Item :lotus.domino.Item]'
这就是我的网页的样子
这可能是什么原因
谢谢
托马斯
另请参阅此问题 如何正确删除 MIME 附件