http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=197408
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=194067

解决方案 »

  1.   

    import lotus.domino.*;
    import java.util.Vector;
    import java.util.Enumeration;public class JavaAgent extends AgentBase {
    public void NotesMain() {
    try {
    Session session = getSession();
    AgentContext agentContext =
    session.getAgentContext();
    // (Your code goes here)
    Database db = agentContext.getCurrentDatabase();
    DocumentCollection dc = db.getAllDocuments();
    Document doc = dc.getFirstDocument();
    Enumeration items = doc.getItems().elements();
    while (items.hasMoreElements()) {
    System.out.println("******");
    Item item = (Item)items.nextElement();System.out.println("Name: " + item.getName());
    String type = "Undefined";
    switch (item.getType()) {
    case Item.ATTACHMENT :
    type = "Attachment"; break;
    case Item.EMBEDDEDOBJECT :
    type = "Embedded object"; break;
    case Item.ERRORITEM :
    type = "Error item"; break;
    case Item.NAMES :
    type = "Names"; break;
    case Item.AUTHORS :
    type = "Authors"; break;
    case Item.READERS :
    type = "Readers"; break;
    case Item.NOTELINKS :
    type = "Note links"; break;
    case Item.NOTEREFS :
    type = "Note references"; break;
    case Item.NUMBERS :
    type = "Numbers"; break;
    case Item.RICHTEXT :
    type = "Rich text"; break;
    case Item.TEXT :
    type = "Text"; break;
    case Item.SIGNATURE :
    type = "Signature"; break;
    case Item.DATETIMES :
    type = "Date-times"; break;
    case Item.UNAVAILABLE :
    type = "Unavailable"; break;
    case Item.UNKNOWN :
    type = "Unknown"; break;
    case Item.USERDATA :
    type = "User data"; break;
    case Item.USERID :
    type = "User ID"; break;
    }
    System.out.println("Type: " + type);
    if (item.isEncrypted())
    System.out.println("Is encrypted");
    if (item.isSigned())
    System.out.println("Is signed");
    if (item.isSummary())
    System.out.println("Is summary");
    if (item.isProtected())
    System.out.println("Is protected");
    System.out.println("Text:\n" + item.getText());}
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
      

  2.   

    This example shows an agent that gets the NoteID of a document using the
    runOnServer method via another agent that executes the getParameterDocID
    method.import lotus.domino.*;
    import java.util.*;
    public class JavaAgent extends AgentBase {
    public void NotesMain() {
    try {
    Session session = getSession();
    AgentContext agentContext = session.getAgentContext();
    // (Your code goes here)
    Database db = agentContext.getCurrentDatabase();
    Agent ag1 = agentContext.getCurrentAgent();
    Agent ag2 = db.getAgent("AgentGetParameterDocID");
    Document doc = db.createDocument();
    doc.replaceItemValue("AgentList", ag1.getName() +
    " performing agent.run(NoteID)");
    doc.save(true,true);
    String paramid = doc.getNoteID();
    ag2.runOnServer(paramid);
    doc.recycle();
    Document doc2 = db.getDocumentByID(paramid);
    Vector v = doc2.getItemValue("AgentList");
    String sAgList = (String)v.elementAt(0);
    System.out.println("Agent calling sequence: " +
    sAgList );
    doc2.remove(true);
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    }
    AgentGetParameterDocIDimport lotus.domino.*;
    import java.util.*;
    public class JavaAgent extends AgentBase {
    public void NotesMain() {
    try {
    Session session = getSession();
    AgentContext agentContext = session.getAgentContext();
    Database db = agentContext.getCurrentDatabase();
    Agent ag1 = agentContext.getCurrentAgent();
    String paramid = ag1.getParameterDocID();
    Document doc = db.getDocumentByID(paramid);
    Vector v = doc.getItemValue("AgentList");
    String sAgList = (String)v.elementAt(0);
    doc.replaceItemValue("AgentList", sAgList +
    " > " + ag1.getName());
    doc.save(true,true);
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    }
      

  3.   

    附件id关键是看你的domino是怎么处理附件的,是直接挂在本文档下,还是挂在另一个文档下,两个文档通过文档id(DocID)关联?在一个文档下的话直接用NoteDocument.etAttachment得到附件~
    import lotus.domino.*;
    public class JavaAgent extends AgentBase {
      public void NotesMain() {
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          DocumentCollection dc = db.getAllDocuments();
          Document doc = dc.getFirstDocument();
          while (doc != null) {
            EmbeddedObject obj = 
                    doc.getAttachment("forest.bmp");
            if (obj != null) {
              System.out.println("Found " + obj.getName() +
                    " in \"" + doc.getItemValueString(
                    "Subject") + "\"");
              break; }
            doc = dc.getNextDocument(); }
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }