Hi, I have an agent that sends emails to selected users, what I would like to do is to change email format to be MIME type. Here is the code, does anybody can see what is wrong there. Text still is shown as text without formating(I just testing here the output).
Thanx
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Stream stream = session.createStream();
session.setConvertMIME(false); // Do not convert MIME to RT
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.replaceItemValue("Form", "Memo");
MIMEEntity body = doc.createMIMEEntity();
MIMEHeader header = body.createHeader("Subject");
header.setHeaderVal("MIME message");
header = body.createHeader("To");
header.setHeaderVal("Robert Ficek");
stream.writeText("<html><head><title>Sample HTML email via MIME</title></head></html");
body.setContentFromText(stream, "text/plain;charset=UTF-8",
MIMEEntity.ENC_NONE);
stream.close();
doc.send(false);
} catch(Exception e) {
e.printStackTrace();
}
The output that I get is
Sample HTML email via MIME