Free Support Forum - aspose.com

How to add calendar info from ics and contact info from vcard to PST file

Greetings!


Please advise how to load calendar info in ICS format from a InputStream and insert into a PST file.

There is no constructor or static method in MapiCalendar that takes an InputStream?

For example, to add a message to a PST file, I use the following:

MailMessage message = MailMessage.load(is, FileCompatibilityMode.SkipValidityChecking);MapiMessage mapimsg = MapiMessage.fromMailMessage(message,OutlookMessageFormat.Unicode);
rootFolder.addMessage(mapimsg);

How do I accomplish the same thing when I have ICS or VCard data and I wish to add a calendar entry or contact to the PST file?

Thanks

Jamie





Hi Jamie,


Thank you for writing to us.

Please have a look at the following source code that loads an appointment from ICS file and adds it to the PST. Please let us know if you have any additional query/inquiry related to Aspose.Email.

Example Code:

Appointment appointment = Appointment.Load(“Test.ics”); <o:p></o:p>

// Save the appointment to disk in ICS format

MemoryStream memStream = new MemoryStream();

appointment.Save(memStream, AppointmentSaveFormat.Ics);

MailMessage mailMsg = new MailMessage();

mailMsg.AddAlternateView(appointment.RequestApointment());

MapiMessage mapiMsg = MapiMessage.FromMailMessage(mailMsg);

// Create new PST

PersonalStorage pst = PersonalStorage.Create("TestCalendar.pst", FileFormatVersion.Unicode);

// Add new folder "Calendar"

pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);

FolderInfo folderInfo = pst.GetPredefinedFolder(StandardIpmFolder.Appointments);

folderInfo.AddMessage(mapiMsg);