Examples: OnBehalfOf property
This agent sends mail with ownership and user information, including on whose behalf the agent runs.
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)
Agent agent = agentContext.getCurrentAgent();
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.appendItemValue("Form", "Memo");
doc.appendItemValue("SendTo",
agentContext.getEffectiveUserName());
doc.appendItemValue("Subject",
"Owner, user, effective user, on behalf of");
RichTextItem body = doc.createRichTextItem("Body");
body.appendText("Owner = " + agent.getOwner());
body.addNewLine(1);
body.appendText("User= " + session.getUserName());
body.addNewLine(1);
body.appendText("Effective user = " +
agentContext.getEffectiveUserName());
body.addNewLine(1);
String behalf = agent.getOnBehalfOf();
if (behalf.length() == 0) behalf = "-Self-";
body.appendText("On behalf of = " + behalf);
body.addNewLine(1);
doc.send(false);
} catch(Exception e) {
e.printStackTrace();
}
}
}