接着之前的Java代理Lotus邮件的讲。
在对邮件进行业务处理不多:标记(取消),回复,回复全部,转发,删除,搜索联系人,搜索邮件内容。
标记:
<span style="font-size:14px;">/**
* 标记
*/
public static void setFollowUp(Document document, String followUpLevel) {
try {
if (document.hasItem("FollowUpStatus")) {
document.replaceItemValue("FollowUpStatus", followUpLevel);
} else {
document.appendItemValue("FollowUpStatus", followUpLevel);
}
if (!document.hasItem("$Nopurge")) {
document.appendItemValue("$Nopurge", "");
}
if (!document.hasItem("$Alarm")) {
document.appendItemValue("$Alarm", "");
}
/**
* 保存
*/
if (document.save()) {
/**
* 成功
*/
} else {
/**
* 失败
*/
}
} catch (NotesException e) {
e.printStackTrace();
} finally {
/**
* 释放资源
*/
if (document != null) {
try {
document.recycle();
} catch (NotesException e) {
e.printStackTrace();
}
}
}
}
/**
* 取消标记
*/
public static void cancelFollowUp(Document document) {
try {
if (document.hasItem("FollowUpStatus")) {
document.replaceItemValue("FollowUpStatus", "");
}
/**
* 保存
*/
if (document.save()) {
/**
* 成功
*/
} else {
/**
* 失败
*/
}
} catch (NotesException e) {
e.printStackTrace();
} finally {
/**
* 释放资源
*/
if (document != null) {
try {
document.recycle();
} catch (NotesException e) {
e.printStackTrace();
}
}
}
}
</span>
这里代码很少,因为还有一些问题我依旧不是很了解,但是这里也基本解决了取消和标记的功能(好像还有一个时间提醒)。
回复(全部):
<span style="font-size:14px;">// 创建新邮件
replyDocument = database.createDocument();
// 修改为回复邮件
replyDocument.makeResponse(document);
// 邮件头
replyDocument.appendItemValue("form",
MailContent.DOCUMENT_FORM_REPLY);</span>
回复邮件需要创建邮件并使用Reply的邮件类型而不是Memo,而第二个方法makeResponse方法将被回复的邮件作为参数放置进去是为了解决LotusWin端上的功能问题(提供一个回复邮件的点击,跳转至被回复的邮件里)。之后就可以以发送邮件的方式进行处理。
转发:
转发邮件和发送普通邮件差不多,Form为Memo类型。其他的随便怎么写,建议在邮件文本最后谈价邮件转发标识(转发邮件的基本内容,),让收件人知道这是转发的邮件就可以了
删除:
<span style="font-size:14px;">/**
* 删除
*/
public static boolean deleteMail(Document document) {
boolean flag = false;
try {
document.remove(true);
} catch (NotesException e) {
e.printStackTrace();
} finally {
/**
* 释放资源
*/
if (document != null) {
try {
document.recycle();
} catch (NotesException e) {
e.printStackTrace();
}
}
flag = true;
}
return flag;
}
</span>
搜索联系人:
搜索联系人的时候选择的不是用户的数据而是names.nsf文件里面的数据
这里有几种方法:search(),ftSearch(),getAllDocumentsByKey()(至今没成功过)。
在此之前有一个注意的地方:官方文档中强调搜索的数据在5000以下,表示数据库上面的数据如果达到了5000则自动取消本次搜索,当然是不使用公式的前提下。在达到5000容量并且不适用公式搜索的话需要对服务器端的Nots.ini文件中添加两个常数来增加该搜索量,TEMP_INDEX_MAX_DOC 和 FT_MAX_SEARCH_RESULTS。
使用公式则避免了上述的麻烦,搜索联系人首先要进入Database
database = session.getDatabase(session.getServerName(),”names.nsf“, false);
通过database的search方法来搜索所需要的内容,首先要知道公式,和数据库很像
form='person'&@Contains(Owner;'要搜索的名字')
搜索邮件内容:
内容则需要添加更多的可能:
form=‘memo’|form='reply'&@Contains(Subject;'搜索的内容')|.......................
最后还有发送Lotus邮件