logo

New Response

« Return to the main article

You are replying to:

  1. Great article, however I needed this logic within a web application (to use Domino as a mail-server from within an iSeries application).

    As other people might be in the same situation I submit the translation to Java of the lotusscript code.

    The application makes a connection to the Domino server through DIIOP to get a global notes Session parameter. Then this is used in the sendhtmlmail method.

    If people need the full application, I can send the jar file through e-mail.

    /** * Connects to the Domino application server, and sends an email. * * * @param sendTo * @param copyTo * @param subject * @param message * @param htmlMessage */ public void sendHtmlMail(String sendTo, String copyTo, String subject, String message, String htmlMessage) { lotus.domino.Document memo = null; try { this.m_dominoSession.setConvertMime(false); // MIME gebruiken i.p.v. Rich Text memo = m_dominoMailDb.createDocument(); memo.appendItemValue("Form", "Memo"); // memo.appendItemValue("Importance", "1"); memo.appendItemValue("CopyTo", copyTo); memo.appendItemValue("Subject", subject); // Nu gaan we een MIME entity aanmaken lotus.domino.MIMEEntity body = memo.createMIMEEntity(); // MIME headers aanmaken lotus.domino.MIMEHeader header = body.createHeader("MIME-Version"); header.setHeaderVal("1.0"); header = body.createHeader("Content-Type"); header.setHeaderValAndParams( "multipart/alternative;boundary=\"=NextPart_=\""); // Add plain text part lotus.domino.MIMEEntity child = body.createChildEntity(); lotus.domino.Stream stream = this.m_dominoSession.createStream(); stream.writeText(message); child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE); stream.close(); // Add html part child = body.createChildEntity(); stream = this.m_dominoSession.createStream(); stream.writeText("<html>", Stream.EOL_CR); stream.writeText("<head>", Stream.EOL_CR); stream.writeText("<style>body{font-family:verdana,arial,helvetica,sans-serif}a{c olor:orange}</style>", Stream.EOL_CR); stream.writeText("</head>", Stream.EOL_CR); stream.writeText("<body>", Stream.EOL_CR); stream.writeText(htmlMessage, Stream.EOL_CR); stream.writeText("</body>", Stream.EOL_CR); stream.writeText("</html>", Stream.EOL_CR); child.setContentFromText(stream, "text/html;charset=\"iso-8859-1\"", MIMEEntity.ENC_NONE); stream.close(); // Send Message memo.send(false, sendTo); System.out.println("HTML bericht " + subject + " verzonden."); } catch (NotesException e) { System.out.println("Error - " + e.id + " " + e.text); // e.printStackTrace( System.out ); } finally { try { if (! (memo == null )) { memo.recycle(); memo = null; } this.m_dominoSession.setConvertMime(true); // restore default } catch (NotesException fe) {} } }

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: