JAVA/CORBA CLASSES
Examples: getNthHeader method
1. This agent displays the Subject header 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) {
MIMEHeader header = mime.getNthHeader("Subject");
if (header != null) {
System.out.println("Subject: " + header.getHeaderVal());
}
else System.out.println("No Subject header");
}
else
{
System.out.println
("Not MIME - " + doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
// Restore conversion
session.setConvertMIME(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent displays all 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();
}
}
}
See Also
getNthHeader method
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary