//Sample Code for Adding and Retrieving Attachments from 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.add(new MailAddress("email@example.com", "Attendee"));
WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);
Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",
new MailAddress("firstname.lastname@example.org", "Organizer"), attendees, expected);
//Attach a file from disc to this appointment
File file = new File("OutputXLS.xls");
FileInputStream fis = new FileInputStream(file);
Attachment att = new Attachment(fis, file.getName());
String savedFile = "appWithAttachments.ics";
Appointment app2 = Appointment.load(savedFile);
System.out.println("Total Attachments: " + app2.getAttachments().size());
for (int i=0; i< app2.getAttachments().size();i++)
att = app2.getAttachments().get(i);
//Save the attachment to disc
This technical tip enables Java developers to
create, add & retrieve attachments from calendar items in Java Apps using Aspose.Email for Java.
Aspose.Email lets developers manage attachments with email messages
using the MailMessage and MapiMessage class. Microsoft Outlook allows you to add as well as retrieve attachments from calendar items, that is ICS. This article shows how the same can be achieved using Aspose.Email for Java for ICS files. Aspose.Email provides an attachments collection that can be used to add and retrieve attachments associated with calendar items. This article shows how to:
- Create and add attachments to an Appointment class object.
- Retrieve attachments information an appointment.
- Extract attachments from an appointment.