无法使用icalendar将Lotus Notes的会议请求发送到microsoft exchange

时间:2013-02-07 06:02:37

标签: lotus-domino icalendar

这是我的代码。请提出必要的修改,以便将莲花的会议请求发送给交换。我收到一封空白邮件,并没有莲花和exchange.do中的任何内容我需要将详细信息直接添加到lotus文档中,除了.ics文件?

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();
}
}
}

1 个答案:

答案 0 :(得分: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中):

Is it possible to upload an image file using AJAX to Domino Server?

您的情况下不需要Base64编码。