请问如何在一个java类中取得lotus notes 的session

peak181 2003-02-25 03:58:16
rt
想用一个类调用本地的notes发一封邮件
...全文
153 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fortoo 2003-05-30
  • 打赏
  • 举报
回复
up
JJanny 2003-02-27
  • 打赏
  • 举报
回复
是一下下面的代码,从domino中读数据:
package com.dreamtel.prjmng;

import lotus.domino.*;
import java.util.*;
import java.io.*;

public class platform6 implements Runnable
{
String host="172.16.6.60", user="admin", pwd="password";

String server = null;
// the dir to save xml
String dir = "c:\\xml";
// max record to read
int max = 20;
// no use in this example
Boolean done = null;

public static void main(String argv[])
{

platform6 t = new platform6();
Thread nt = new Thread((Runnable)t);
nt.start();
}
public platform6()
{

}


public void run()
{
BufferedOutputStream out = null;
try
{
Session s = NotesFactory.createSession(
host, user, pwd);
String p = s.getPlatform();
System.out.println("Platform = " + p);

Database fw = s.getDatabase("lotusr6/ibm", "names.nsf");
String filepath = null;

DocumentCollection dc =
fw.search("@Contains(Form; \"FWDL\")");
Document doc = dc.getFirstDocument();
int count = 0;
while(doc != null && count < max ){

String F_WJBT = doc.getItemValueString("F_WJBT");
String F_FWBM = doc.getItemValueString("F_FWBM");
int F_FWBH = doc.getItemValueInteger("F_FWBH");
System.out.println(count);
Vector v = doc.getItemValue("F_QFRQ");
DateTime F_QFRQ = null;
if(v != null && v.size() > 0){
F_QFRQ = (DateTime)v.get(0);
}

String F_WJNR = doc.getItemValueString("F_WJNR");
if(F_WJBT == null)
F_WJBT = "";
if(F_FWBM == null)
F_FWBM = "";
if(F_WJNR == null)
F_WJNR = "";
String xml = generateXML(F_WJBT , F_FWBM , F_FWBH,
F_QFRQ.toString(), F_WJNR);
xml = "<?xml version='1.0' encoding='gb2312'?>" + xml;
count ++;
filepath = dir + File.separator + count + ".xml";
out = new BufferedOutputStream(new FileOutputStream(filepath));
out.write(xml.getBytes());
out.close();
doc = dc.getNextDocument();

}
}
catch (Exception e)
{
System.err.println(e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
done = new Boolean(true);
System.out.println(done);
}

private String generateXML(String WJBT,String FWBM,int FWBH, String QFRQ, String
WJNR){
StringBuffer sb = new StringBuffer();
sb.append("<record>");
sb.append("<wjbt>" + WJBT + "</wjbt>");
sb.append("<fwbm>" + FWBM + "</fwbm>");
sb.append("<fwbh>" + FWBH + "</fwbh>");
sb.append("<qfrq>" + QFRQ + "</qfrq>");
sb.append("<wjnr>" + WJNR + "</wjnr>");
sb.append("</record>");
return sb.toString();
}

}
peak181 2003-02-25
  • 打赏
  • 举报
回复
都设了
编译没有问题
是运行出的问题
jhlqab 2003-02-25
  • 打赏
  • 举报
回复
把那些JAR文件设进去就可以了。主要是设置classpath和path
peak181 2003-02-25
  • 打赏
  • 举报
回复
nlsxbe 是一个DLL文件
我不知道如何才能把它设进去
:)
好象没有相关的问题
问了也没人回答
555
jhlqab 2003-02-25
  • 打赏
  • 举报
回复
你的JAVA运行环境都没有配置好,找找这方面的资料吧,报错是找不到路径。
peak181 2003-02-25
  • 打赏
  • 举报
回复
报下面的错:
应该如何设置

java.lang.UnsatisfiedLinkError: no nlsxbe in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)

at java.lang.Runtime.loadLibrary0(Runtime.java:788)

at java.lang.System.loadLibrary(System.java:832)

at lotus.domino.NotesThread.load(NotesThread.java:281)

at lotus.domino.NotesThread.checkLoaded(NotesThread.java:301)

at lotus.domino.NotesThread.initThread(NotesThread.java:139)

at lotus.domino.NotesThread.run(NotesThread.java:197)

jhlqab 2003-02-25
  • 打赏
  • 举报
回复
import java.util.*;
import lotus.domino.*;
public class sessionprops extends NotesThread
{
public static void main(String argv[])
{
sessionprops t = new sessionprops();
t.start();
}
public void runNotes()
{
try
{
Session s = NotesFactory.createSession();
System.out.println("User name = " +
(String)s.getUserName());
Name no = s.getUserNameObject();
if (no.isHierarchical())
System.out.println("Common name = " +
(String)s.getCommonUserName());
System.out.println("Domino " +
(String)s.getNotesVersion() + " running on " +
(String)s.getPlatform());
System.out.println("***Address books***");
Database db;
Vector books = s.getAddressBooks();
Enumeration e = books.elements();
while (e.hasMoreElements()) {
db = (Database)e.nextElement();
String fn = db.getFileName();
String server;
if (db.getServer() != null)
server = db.getServer();
else
server = "Local";
String title = db.getTitle();
System.out.println(server + " " + fn + " \"" +
title + "\"");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧