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:
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("attendee_address@domain.com", "Attendee"));
WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);
Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",
startDate, endDate,
new MailAddress("organizer_address@domain.com", "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());
app.getAttachments().add(att);
fis.close();
String savedFile = "appWithAttachments.ics";
app.save(savedFile, AppointmentSaveFormat.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);
System.out.println(att.getName());
//Save the attachment to disc
att.save(att.getName());
}
Overview: Aspose.Email for Java
Aspose.Email for Java is a Non-Graphical Java component that enables Java applications to read and write MS Outlook MSG files from within a Java application without using MS Outlook. It enables developers to create new MSG file from scratch, update an existing MSG file, read Outlook MSG file & get its properties like subject, body, recipients in to, cc and bcc, adding or removing attachment, sender information & MAPI properties. Aspose.Email can be used with Web as well as Desktop Application.
- Create and add attachments to an Appointment class object.
- Retrieve attachments information an appointment.
- Extract attachments from an appointment.
[Java]
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("attendee_address@domain.com", "Attendee"));
WeeklyRecurrencePattern expected = new WeeklyRecurrencePattern(3);
Appointment app = new Appointment("Appointment Location", "Appointment Summary", "Appointment Description",
startDate, endDate,
new MailAddress("organizer_address@domain.com", "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());
app.getAttachments().add(att);
fis.close();
String savedFile = "appWithAttachments.ics";
app.save(savedFile, AppointmentSaveFormat.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);
System.out.println(att.getName());
//Save the attachment to disc
att.save(att.getName());
}
Overview: Aspose.Email for Java
Aspose.Email for Java is a Non-Graphical Java component that enables Java applications to read and write MS Outlook MSG files from within a Java application without using MS Outlook. It enables developers to create new MSG file from scratch, update an existing MSG file, read Outlook MSG file & get its properties like subject, body, recipients in to, cc and bcc, adding or removing attachment, sender information & MAPI properties. Aspose.Email can be used with Web as well as Desktop Application.
- Homepage of Aspose.Email for Java
- Download Aspose.Email for Java
No comments:
Post a Comment