0

这是我的代码。请建议进行必要的更改以将会议请求从 Lotus 发送到 Exchange。我收到一封空白邮件,在 lotus 和 exchange 中都没有内容。除了 .ics 文件之外,我还需要将详细信息直接添加到 lotus 文档中吗?

public class ICalendarSample {

public static void main(String[] args) {

// Creating a new calendar
Calendar calendar = new Calendar();
calendar.getProperties().add(new ProdId("-//Lotus Development Corporation//NONSGML Notes 8.5.1//EN_S"));
calendar.getProperties().add(Version.VERSION_2_0);

// start time
java.util.Calendar startCal = java.util.Calendar.getInstance();
startCal.set(2013, 05, 11, 15, 00);

// end time
java.util.Calendar endCal = java.util.Calendar.getInstance();
endCal.set(2013, 05, 11, 15, 30);

SimpleDateFormat sdFormat = new SimpleDateFormat("yyyyMMdd'T'hhmmss'Z'");
String strDate = sdFormat.format(startCal.getTime());

net.fortuna.ical4j.model.Date startDt = null;
try {
startDt = new net.fortuna.ical4j.model.Date(strDate);

long diff = endCal.getTimeInMillis() - startCal.getTimeInMillis();
int min = (int) (diff / (1000 * 60));
Dur dur = new Dur(0, 0, min, 0);

// Creating a meeting event
VEvent meeting = new VEvent(startDt, dur, "Meeting Subject");
meeting.getProperties().add(new Uid("nitin1234"));
meeting.getProperties().add(new Organizer());
meeting.getProperties().getProperty(Property.ORGANIZER)
.setValue("xx");
meeting.getProperties().add(new Attendee());
meeting.getProperties().getProperty(Property.ATTENDEE)
.setValue("xx");

String calFile = "TestCalendar.ics";
FileOutputStream fout = null;
fout = new FileOutputStream(calFile);
CalendarOutputter outputter = new CalendarOutputter();
outputter.setValidating(false);
outputter.output(calendar, fout);

System.out.println(meeting);
File f;
f = new File("TestCalendar.ics");
f.createNewFile();
FileWriter fstream = new FileWriter("TestCalendar.ics", true);
BufferedWriter fbw = new BufferedWriter(fstream);
fbw.write(meeting.toString());
fbw.close();

Session s;

s = NotesFactory.createSessionWithIOR(Strings.IOR, "xx","xx");
Database db = s.getDatabase("xxx", "xxx");
Document doc = db.createDocument();
s.setConvertMime(false);
doc.replaceItemValue("Form", "Memo");
MIMEEntity body = doc.createMIMEEntity("body");
MIMEHeader header = body.createHeader("Content-class");
header.setHeaderVal("urn:content-classes:calendarmessage");
header = body.createHeader("Content-Type");
header.setHeaderValAndParams("text/calendar; Method=Request; name=\"TestCalendar.ics\"");
header = body.createHeader("Content-Transfer-Encoding");
header.setHeaderVal("8bit");
s.setConvertMime(true);
doc.save();
doc.send("xxx");

} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (NotesException e) {
e.printStackTrace();
} catch (ValidationException e) {
e.printStackTrace();
}
}
}
4

1 回答 1

1

setHeaderValAndParams有参数时使用:

header = body.createHeader("Content-Type");
header.setHeaderValAndParams("text/calendar; method=REQUEST; name=\"meeting.ics\"");
header = body.createHeader("Content-Transfer-Encoding");
header.setHeaderVal("8bit");

以下是添加文件的方法(在 LotusScript 中):

是否可以使用 AJAX 将图像文件上传到 Domino 服务器?

您的情况不需要 Base64 编码。

于 2013-02-07T07:37:52.867 回答