示例 3:用邮件数据库信息生成报告
最后一个示例使用广泛。这里我们循环通过 Domino 服务器上的邮件数据库并用来自每个邮件文件的各个项创建一个电子邮件报告。首先,花些时间看一下清单 14 中的 LotusScript 示例。
清单 14. LotusScript 代码示例
1 Dim session As New Notessession
2 Dim nab As New Notesdatabase("Enter_Server_Name_Here", "names.nsf")
3 Dim reportDatabase As Notesdatabase
4 Dim personDocument As NotesDocument
5 Dim report As NotesDocument
6 Dim view As NotesView
7 Dim temp As String
8 Set reportDatabase = session.CurrentDatabase
9 Set report = reportDatabase.CreateDocument
10 Call report.ReplaceItemValue("Form" , "Memo")
11 Call report.ReplaceItemValue("Subject" , "Mail Applications Report")
12 Dim richTextItem As New NotesRichTextItem(report, "Body")
13 Set view = nab.GetView("People")
14 Set personDocument = view.GetFirstDocument
15 While Not personDocument Is Nothing
16 On Error Resume Next
17 Dim mailDatabase As New NotesDatabase(personDocument.mailserver(0),
personDocument.mailfile(0))
18 If mailDatabase.IsOpen Then
19 temp = "Mail Owner: " & personDocument.fullname(0) & " Size: " &
Cstr(mailDatabase.size) & " _ bytes Template: "
+ mailDatabase.DesignTemplateName
20 Else
21 temp = "Could not open mail file for: " & personDocument.fullname(0) &
" Server: " & personDocument.mailserver(0) & " , "
& personDocument.mailfile(0)
22 End If
23 richTextItem.AppendText(temp)
24 richTextItem.AddNewline( 1)
25 temp = ""
26 Set personDocument = view.GetNextDocument(personDocument)
27 Wend
28 Call report. Send(False, "Enter_Email_Address_Here")
在IBM Lotus Domino Designer中使用Java构建应用程序(12)
时间:2011-01-24 IBM Oscar Hernandez
我们从第 1--7 行开始(在清单 14 中),声明需要的变量,然后初始化 nab Database 变量。在 Java 中,注意必须使用 session 对象来设置 nab(请参见清单 15)。
清单 15. 声明变量
import lotus.domino. *;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database nab;
nab = session.getDatabase("Enter_Server_Name_Here","names.nsf");
Database reportDatabase;
Document personDocument;
Document report;
Document tempDocument;
View view;
String temp;
} catch(Exception
|