【问题标题】:Automate mails in Lotus Notes在 Lotus Notes 中自动化邮件
【发布时间】:2012-01-10 08:04:57
【问题描述】:

我们需要从 JSP 页面打开 Lotus Notes 客户端。

目前在 JSP 中,我们使用 ActiveXObject(Outlook.Application) 打开 Microsoft Outlook 客户端

发件人电子邮件、收件人电子邮件、电子邮件主题和电子邮件正文应从请求范围中填充。我得到了一种解决方案,但只能直接发送邮件,我需要打开 Lotus Notes 页面。有一些方法,如sendtoformcreate。输入所有详细信息后单击提交按钮时,是否有任何方法可以打开撰写邮件选项?不仅是 JavaScript。如果解决方案是 Java 也没有问题。

基本上,用户只需单击页面上的某个链接,然后 Lotus Notes 客户端就会打开预先填充的信息。最后,用户将查看电子邮件内容,在电子邮件正文中添加他们需要添加的任何消息,然后最终发送电子邮件。如果可能的话,也把代码发给我。

【问题讨论】:

  • 如果这些答案之一对您有帮助,请接受它作为答案。

标签: java javascript lotus-notes


【解决方案1】:

根据您的帖子here,当您想使用前端/UI 功能时,您似乎正在使用后端类。

我同意this post- 如果可能,您应该使用mailto: link 来实现此功能。如果 Lotus Notes 是他们的默认电子邮件程序,mailto: 链接将启动 Notes 客户端,撰写备忘录并使用您指定的任何内容填充您想要的字段。

如果 mailto: 无法满足您的需求,您可以尝试使用“Lotus Notes 自动化类”中的前端类。这是 CodeProject 帖子中示例代码的修改版本:

<!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】:

    它应该大致像这样工作。自从我实施这个以来已经有一段时间了。如果我没记错的话,你应该:

    1. 按照本教程在 Lotus Notes 中创建会话:http://www.ibm.com/developerworks/lotus/library/ls-Java_access_pt1/index.html

    2. 在目标邮件数据库中编写memo 形式的新文档并填写必填字段。比如:

      文档 doc = db.createDocument("Memo");
      doc.setItemValue("主题", "我的主题");
      doc.setItemValue("SendTo", "MyEmailAddresses");
      
      RichTextItem rti = doc.getFirstItem("Body");
      rti.addText("MyMailContent");
      
      doc.save();
    3. 获取您之前使用doc.getUrl() 创建的文档的 URL,并将此 URL 显示为 JSP 上的链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多