Administration Services Console has integrated support for sending e-mail using the JavaMail API. We have wrapped the classes and provide a dialog for sending e-mail. There is also support in the InternalFrame class to send from any class derived from the CInternalFrame class.
The following is a simple example of how to send the contents of a text area in an e-mail from a dialog.
Import com.essbase.eas.ui.email.*; public void email() { JFrame fr = ConsoleManager.getConsoleFrame(); SendEmail email = new SendEmail(fr, fr.getTitle(), new Object[] { getTextArea().getText()} ); email.send(); }
The following example is for a window derived from CInternalFrame. The methods, isEmailable() and getObjectsToEmail, are methods in the CInternalFrame class.
public boolean isEmailable() { return true; } public Object[] getObjectsToEmail() { HTMLDoc doc = new HTMLDoc(); doc.setTitle(getTitle()); doc.addObject(doc.getHeading(2, doc.getStyleText(getTitle(), doc.BOLD | doc.UNDERLINE), doc.CENTER)); doc.addObject(doc.BR); doc.addObject(TableUtilities.getHTML((DefaultTableModel)locksTable.getModel())); return (new Object[] { new EmailAttachment(doc.toString(), "Locks.htm", EmailAttachment.HTMLTEXT, "", EmailAttachment.ATTACHMENT)}); }