天天看点

[Domino]Java访问Domino邮件代码片断[3]

编写者

日期

关键词

郑昀@ultrapower

2005-7-1

java domino

3个知识点:

1:需要通过noteid来定位该邮件:

database dbmail = snotes.getdatabase(snotes.getservername(),

                      mailfile, false);

document doc = dbmail.getdocumentbyid(noteid);

2:通过document的createdocument方法创建一个新文档,然后通过document的copyallitems方法将原邮件的所有字段复制过来。

3:通过replaceitemvalue方法将部分字段的数值替换。

代码片段:

if (doc != null)

{

                       document forward = dbmail.createdocument();

                       // given a destination document, copies all of the items in

                       // the current document into the destination document.

                       // the item names are unchanged.

                       // 第2个参数解释如下:

                       // replace

                       // boolean. if true, the items in the destination

                       // document are replaced. if false (default),

                       // the items in the destination document are appended.

                       doc.copyallitems(forward, true);

                       item itemsubject = doc.getfirstitem("subject");

                          string stritemre = "转发:" + itemsubject.gettext();

                          forward.replaceitemvalue("subject",

                                        stritemre);

                          forward.replaceitemvalue("recipients", to);

                          forward.replaceitemvalue("sendto", to);

                          forward.setsavemessageonsend(true);

                          forward.send(to);

}

这种转发方式,会将原邮件的附件一并转发。