Examples: MIMEHeader class
- This agent displays the names and values of the headers of a MIME
entity.
import lotus.domino.*; import java.util.Vector; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) Stream stream = session.createStream(); // Do not convert MIME to rich text session.setConvertMIME(false); DocumentCollection dc = agentContext.getUnprocessedDocuments(); Document doc = dc.getFirstDocument(); while (doc != null) { MIMEEntity mime = doc.getMIMEEntity(); if (mime != null) { System.out.println(doc.getItemValueString("Subject")); Vector headers = mime.getHeaderObjects(); for (int j = 0; j < headers.size(); j++) { MIMEHeader header = (MIMEHeader)headers.elementAt(j); System.out.println(header.getHeaderName() + ": " + header.getHeaderVal()); } } else { System.out.println("Not MIME - " + doc.getItemValueString("Subject")); } doc = dc.getNextDocument(doc); } // Restore conversion session.setConvertMIME(true); } catch(Exception e) { e.printStackTrace(); } } }
- This agent displays the Received headers of a MIME entity.
import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) // Do not convert MIME to rich text session.setConvertMIME(false); DocumentCollection dc = agentContext.getUnprocessedDocuments(); Document doc = dc.getFirstDocument(); while (doc != null) { MIMEEntity mime = doc.getMIMEEntity(); if (mime != null) { int n = 1; MIMEHeader header = mime.getNthHeader("Received", n); while (header != null) { System.out.println ("Received" + n + ": " + header.getHeaderVal()); n = n + 1; header = mime.getNthHeader("Received", n); } } else { System.out.println ("Not MIME - " + doc.getItemValueString("Subject")); } doc = dc.getNextDocument(doc); } // Restore conversion session.setConvertMIME(true); } catch(Exception e) { e.printStackTrace(); } } }