我们需要从 JSP 页面打开 Lotus Notes 客户端。
目前,在 JSP 中,我们使用 ActiveXObject(Outlook.Application)
打开 Microsoft Outlook 客户端
发件人电子邮件、收件人电子邮件、电子邮件主题和电子邮件正文应从请求范围中填充。我得到了一种解决方案,但只能直接发送邮件,我需要打开 Lotus Notes 页面。有一些方法,例如 sendto
、form
、create
。当我们输入所有详细信息后单击“提交”按钮时,是否有任何方法可以打开撰写邮件选项?不仅仅是JavaScript。如果解决方案是用 Java 编写的也没有问题。
基本上,用户只需单击页面上的某个链接,然后 Lotus Notes 客户端就会打开并显示预先填充的信息。最后,用户将查看电子邮件内容,在电子邮件正文中添加他们需要添加的任何消息,然后最终发送电子邮件。如果可能的话也给我发送代码。
最佳答案
根据您的帖子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>
关于java - 在 Lotus Notes 中自动发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8800191/