0

here's my code. pls suggest the necessary changes to send meeting requests from lotus to exchange. I am getting a blank mail wid no content in both lotus and exchange.do i need to add the details directly into the lotus document , in addition to the .ics file?

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 Answers1

1

Use setHeaderValAndParams when you have parameters:

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

Here is how to add a file (this is in LotusScript):

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

No Base64 encoding needed in your case.

Community
  • 1
  • 1
Panu Haaramo
  • 2,932
  • 19
  • 41
  • thanks for the reply Panu . I have another problem. I m not able to add it here. So i have edited my original post. Pls check it and help me out – Nitin Reddy Feb 07 '13 at 10:09
  • Still only the first header is being set. When I create a child and add the header to it Im able to get an .ics attachment in the reciever's mail. But, even the first header is not present in the mail. Also the .ics attachment is being shown as not supported calendar message. – Nitin Reddy Feb 08 '13 at 05:59
  • @NitinReddy Add `doc.save()` before `doc.send()` and then check the Notes document. How do the headers look there? – Panu Haaramo Feb 09 '13 at 07:38
  • I have added the document headers in the original question. pls find it. – Nitin Reddy Feb 11 '13 at 09:53
  • @NitinReddy How does it look like in the sending end? – Panu Haaramo Feb 11 '13 at 10:07
  • im not able to see the header at sender's end(lotus notes). can u help me out regarding how to see the headers in the mail – Nitin Reddy Feb 11 '13 at 11:07
  • @NitinReddy Use `createMIMEEntity("ItemName")` and then you should see the item in document properties. – Panu Haaramo Feb 11 '13 at 12:08
  • what shud i pass in the place of "ItemName" . can u post the complete adding headers code part(all the three headers). im pretty confused. Also, Do i need to make any other changes in any part of my code. – Nitin Reddy Feb 11 '13 at 13:30
  • @NitinReddy Use `createMIMEEntity("Body")`. This is mainly to get the headers readable in Notes. For the final solution I'm not sure if you need to use the item name or not. – Panu Haaramo Feb 11 '13 at 13:37
  • @ Panu Haaramo i've tried the same thing . yet no change. Im changing the question again n posting my latest code again. kindly check my code n suggest any necessary changes. Sorry for troubling u so much. – Nitin Reddy Feb 11 '13 at 15:43
  • "Form" is the only item you see in the document? – Panu Haaramo Feb 11 '13 at 16:00
  • @ Panu Haaramo I didnt get you. Im not sure about the form part. I found it somewhere and just copied it. Well as far as i know i guess form is the only item in the document. Do you want me to add any other item? – Nitin Reddy Feb 11 '13 at 16:35
  • @ Panu Haaramo I think u meant i should use appendItemValue instead of replaceItemValue right? – Nitin Reddy Feb 11 '13 at 16:42
  • Please check the item values with Notes client and document properties box. – Panu Haaramo Feb 11 '13 at 18:32