0
votes

We need to open up the Lotus Notes client from a JSP page.

Currently in the JSP we are opening up the Microsoft Outlook Client using ActiveXObject(Outlook.Application)

The from email, to email, email subject and email body should get populated from the Request Scope. I got one solution but in that it is possible only to send the mails directly I need to open the Lotus Notes page. There are some methods like sendto, form, create. Is there any method which opens the compose mail option when we click the submit button after entering all the details? Not only JavaScript. If the solution is in Java also no problem.

Basically the user would just click some link on a page and then Lotus Notes client should open up with the pre-populated information. Finally the user would review the email contents, add any message they need to add in the email message body and then finally send the email. If possible send me the code also.

2
If one of these answers was helpful to you, please accept it as the answer. - Rob Darwin

2 Answers

2
votes

Based on your post here, it looks like you are currently using back-end classes when you want to be using front-end/UI functionality.

I agree with this post- if possible, you should use a mailto: link for this functionality. If Lotus Notes is their default e-mail program, a mailto: link will launch the Notes client, compose a memo and populate the fields you want with whatever you specify.

If mailto: doesn't give you what you need, you can try using the front-end classes from the "Lotus Notes Automation Classes". Here is a modified version of your sample code from the CodeProject post:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Lotus</title>
    <script language="javascript" type="text/javascript">
function SendScriptMail() {
    var mToMail = document.getElementById('txtMailId').value
    var mSub = document.getElementById('txtSubject').value
    var mMsg = document.getElementById('txtContent').value
    var Session;
    var Maildb;
    var UI;
    var MailDoc;
    try {
        // Create the Activex object for NotesSession
        Session = new ActiveXObject('Notes.NotesSession');
        if (Session == null) {
            throw("NoSession");
        } else {
            // Get mail database
            Maildb = Session.GetDatabase("", "");
            Maildb.OPENMAIL();
            if (Maildb == null) {
                throw("NoMaildb");
            } else {
                // Create the ActiveX object for NotesUIWorkspace
                UI = new ActiveXObject('Notes.NotesUIWorkspace');
                if (UI == null) {
                    throw("NoUI");
                } else {
                    MailDoc=UI.Composedocument(Maildb.SERVER, Maildb.FILEPATH, 'Memo');
                    if (MailDoc == null) {
                        throw('NoMailDoc');
                    } else {
                        // Populate the fields
                        MailDoc.Fieldsettext('SendTo', mToMail);
                        MailDoc.Fieldsettext('Subject', mSub);
                        // insert message body and place cursor at end of text
                        MailDoc.Gotofield('Body');
                        MailDoc.Inserttext(mMsg); 
                        // destroy the objects
                        Session.Close();
                        Session = null;
                        UI = null;
                        Maildb = null;
                        MailDoc = null;
                    }
                }
            }
        }
    } catch (err) {
        // feel free to improve error handling...
        alert('Error while sending mail');
    }
}
    </script>
</head>
<body>
    <table width="100%" height="100%">
        <tr>
            <td width="40%" height="130px">
            </td>
            <td>
            </td>
            <td width="40%">
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <table width="100%">
                    <tr>
                        <td style="color: Black; font-size: 10px; font-family: Verdana; text-align: left;"
                            width="50px" valign="top">
                            Mail Id</td>
                        <td>
                            <input id="txtMailId" style="color: #000000; font-size: 10px; font-family: Verdana;
                                height: 11px; text-align: left; top: auto; border: 1px solid #336699; text-decoration: none;
                                width: 176px;" type="text" maxlength="50" /></td>
                    </tr>
                    <tr>
                        <td style="color: Black; font-size: 10px; font-family: Verdana; text-align: left;"
                            valign="top">
                            Subject</td>
                        <td>
                            <input id="txtSubject" style="color: #000000; font-size: 10px; font-family: Verdana;
                                height: 11px; text-align: left; top: auto; border: 1px solid #336699; text-decoration: none;
                                width: 176px;" type="text" maxlength="50" /></td>
                    </tr>
                    <tr>
                        <td style="color: Black; font-size: 10px; font-family: Verdana; text-align: left;
                            height: 79px;" valign="top">
                            Content</td>
                        <td>
                            <textarea id="txtContent" cols="20" style="color: #000000; font-size: 10px; font-family: Verdana;
                                height: 75px; text-align: left; top: auto; border: 1px solid #336699; text-decoration: none;
                                width: 176px;"></textarea></td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <input id="btnSend" type="button"  onclick="SendScriptMail();" style="font-family: Verdana; font-size: 11px; text-align: center;
                                top: auto; width: 60px; background-color: #A55129; border: 1px solid #336699;
                                text-decoration: none; font-weight: normal; color: #FFFFFF;" value="Send" />
                            <input id="btnCancel" style="font-family: Verdana; font-size: 11px; text-align: center;
                                top: auto; width: 60px; background-color: #A55129; border: 1px solid #336699;
                                text-decoration: none; font-weight: normal; color: #FFFFFF;" type="button" value="Cancel" /></td>
                    </tr>
                </table>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td height="130px">
            </td>
            <td>
            </td>
            <td>
            </td>
        </tr>
    </table>
</body>
</html>
2
votes

It should work like this approximately. Its been a while since I implemented this. If I remember it correctly you should:

  1. Create a session in Lotus Notes by following this tutorial: http://www.ibm.com/developerworks/lotus/library/ls-Java_access_pt1/index.html

  2. Compose a new document of the form memo in the target mail database and fill the required fields. Something like:

    Document doc = db.createDocument("Memo");
    doc.setItemValue("Subject", "My Subject");
    doc.setItemValue("SendTo", "MyEmailAddresses");
    
    RichTextItem rti = doc.getFirstItem("Body");
    rti.addText("MyMailContent");
    
    doc.save();
  3. Get the URL of the document that you created before with doc.getUrl() and present this URL as a link on the JSP.