即时从其他文档复制附件 [英] copy attachment from other document on fly

查看:31
本文介绍了即时从其他文档复制附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我保存当前 XPage 后,在数据源的 postNewDocument 事件中..我会在不保存磁盘的情况下在后端 Domino Document 中即时复制来自另一个文档的附件,我找到了这个解决方案:

After I save my current XPages, in the event postNewDocument of datasources..I would to copy on the fly in the backend Domino Document without saving of disk the attachment from another document andI have found this solution:

  var attachments:java.util.Vector = session.evaluate("@AttachmentNames", docReply);
  for (var i = 0; i < attachments.size(); i++) {
     embeddedObj = docReply.getAttachment(attachments.get(i).toString());
     if (embeddedObj != null) {
       bufferInStream = new java.io.BufferedInputStream(embeddedObj.getInputStream());
     }
  }

如何将每个附件流添加到当前 Domino 文档的 RichTextItem 中?

How how can I add every attachment stream into a RichTextItem of my current Domino Document?

Tnx

1 月 29 日更新: Tnx 到 @Sven 我已将此代码插入到我的 PostSavedocument 事件中..但现在我有另一个问题......似乎损坏了 MIME 我的Body",即 rt mime.

update 29 january 14: Tnx to @Sven I have insert this code into my PostSavedocument event.. But now I have another problem...seem that damage the MIME my "Body" that is the rt mime.

如果我用我的 Notes Client 打开带有这个 RT mime 的文档,我只会看到新的附件,而不是 CKEDITOR 的原始 HTML 内容(如果我评论以下代码......工作正确......现在我有重新编辑存在的 MIME 问题

If I open with my Notes Client the document with this RT mime I see only the new attachments and not the original HTML content of CKEDITOR (If I comment the follow code...work correct)....Now I have the problem to re-edit exist MIME filed

 session.setConvertMime(false);
var doc:NotesDocument=document1.getDocument(true);
var mimeRoot:NotesMIMEEntity=doc.getMIMEEntity("Body");
var docAttach:NotesDocument=database.getDocumentByUNID('XXXXXXXUNID'); //doc where are the attachmetns files MIME or RICHTEXT


var XSPReply=wrapDocument(docAttach);  //function in Xsnippets from Opentntf.org
var listattachs=XSPReply.getAttachmentList("Body");

for (var i=0; i<listattachs.length; i++) {
   var is=null;
   var att = listattachs[i];
   var persistentName = att.getPersistentName()==null?att.getName():att.getPersistentName();
   var cid = att.getCID();
   var eo:NotesEmbeddedObject = docAttach.getAttachment(persistentName);
   if (null != eo) {
      var child:NotesMIMEEntity=mimeRoot.createChildEntity(); //create child of original mail
      var emailHeader:NotesMIMEHeader = child.createHeader("Content-Disposition");
      emailHeader.setHeaderVal("attachment; filename=\"" + persistentName+ "\"");
      emailHeader = child.createHeader("Content-ID");
      emailHeader.setHeaderVal("<" + cid + ">");
      var is = new java.io.BufferedInputStream(eo.getInputStream());
      var stream:NotesStream = session.createStream();
      stream.setContents(is);
      child.setContentFromBytes(stream, att.getType(),NotesMIMEEntity.ENC_IDENTITY_BINARY);
    }
}

doc.closeMIMEEntities(true,"Body")
doc.save()
session.setConvertMime(true);

推荐答案

您可以尝试将附件添加为 MIME 实体.看看这里的例子:链接

You can try to add the attachments as MIME Entities. Have a look here for an example: Link

这篇关于即时从其他文档复制附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆