zoukankan      html  css  js  c++  java
  • [Domino]Java访问Domino邮件代码片断[4]下载某一封邮件中的指定附件

     

    [Domino]Java访问Domino邮件代码片断[4]

    编写者

    日期

    关键词

    郑昀@ultrapower

    2005-8-1

    Java Domino

     

    下载某一封邮件中的指定附件

    3个知识点:

    1:需要通过NoteID来定位该邮件:

    Database dbMail = sNotes.getDatabase(sNotes.getServerName(),

                          mailfile, false);

    Document doc = dbMail.getDocumentByID(noteid);

    2:其次需要通过attachment name来定位该附件:

    EmbeddedObject eAttach =

    (EmbeddedObject)doc.getAttachment(attachmentFileName);

    3:通过EmbeddedObjectextractFile方法下载附件。

    代码片段:

    Database dbMail = sNotes.getDatabase(sNotes.getServerName(),

                          mailfile, false);

    Document doc = dbMail.getDocumentByID(noteid);

    if (doc != null)

    {

           // Given the name of a file attachment, returns a NotesEmbeddedObject

           // representing the attachment. You can use this method to find file

           // attachments which 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.

           EmbeddedObject eAttach =

           (EmbeddedObject)doc.getAttachment(attachmentFileName);

           // 查看附件

           if(eAttach != null)

           {

              logger.info("打开了指定邮件的指定附件");

          

              // 是否是我们要寻找的哪个附件?

              // 是的话,就保存下来

              String strAttachmentFileName =

                     eAttach.getSource();

          

              // Writes a file attachment to storag

              if(strAttachmentFileName.length() > 0)

                     eAttach.extractFile("c:\\" + strAttachmentFileName);

                    

              eAttach.recycle();

            }

    }

     

    这其中的attachmentFileName参数是通过EmbeddedObjectgetName方法拿到的:

    // getName returns a String value containing the name

    // used to reference an object that was embedded programmatically.

    String strAttachmentObjectName =

       eAttach.getName();

    而不是通过getSource()拿到的。当一封邮件中同时存在多个重名附件时,getName()getSource()就不一样了。

     

    编写者

    日期

    关键词

    郑昀@ultrapower

    2005-8-1

    Java Domino

     

  • 相关阅读:
    LeetCode算法题-Find Mode in Binary Search Tree(Java实现)
    LeetCode算法题-Keyboard Row(Java实现)
    LeetCode算法题-Next Greater Element I(Java实现)
    LeetCode算法题-Construct the Rectangle(Java实现)
    月经贴之 适配器 UML 类图 描述
    最近准备面试 ,要求立即各种设计模式
    URL方案最佳做法|高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼
    使用属性创建区域 (Creating Areas with Attributes) | 使用区域 | 高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼
    iOS定位
    iOS本地化
  • 原文地址:https://www.cnblogs.com/zhengyun_ustc/p/204968.html
Copyright © 2011-2022 走看看