Adding Attachments to Calendar Items

Aspose.Email - Adding Attachments to Calendar Items

Aspose.Email provides an attachments collection that can be used to add attachments associated with calendar items.


 Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

calendar.set(2012, Calendar.NOVEMBER, 1, 0, 0, 0);

Date startDate = calendar.getTime();

calendar.set(2012, Calendar.DECEMBER, 1);

Date endDate = calendar.getTime();

MailAddressCollection attendees = new MailAddressCollection();

attendees.addItem(new MailAddress("", "Attendee"));

WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);

Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",

									startDate, endDate,

									new MailAddress("", "Organizer"), attendees, expected);

//Attach a file from disc to this appointment

File file = new File(dataDir + "AsposeXLS.xls");

FileInputStream fis = new FileInputStream(file);

Attachment att = new Attachment(fis, file.getName());



String savedFile = dataDir + "AppWithAttachments.ics";, AppointmentSaveFormat.Ics);

Download Running Code

Download Sample Code