We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

RE:Adding calendar item in subfolder of type calendar in outlook

Hi

I need to add calendar item in subfolder of type calendar.
I am able add mapi calendar item in predefined folder name calendar


>> CreatePredefinedFolder
f_Folder= m_ObjPersonalStorage.CreatePredefinedFolder(“Calendar”,
StandardIpmFolder.Appointments);
>>create sub folder
f_objFolder2 = f_Folder.AddSubFolder(“calendar2”, “IPF.Appoinment”);
f_MapiCalendarObj = new MapiCalendar();
f_objFolder2 .AddMapiMessageItem(f_MapiCalendarObj);
but when
I tried to add mapi calendar item in subfolder it gives me following error

"MessageClass of the item to be added doesn’t supported."

Hi Amol,


Thank you for using Aspose.Email.

Please try the following code at your end which adds a MapiCalendar object to a subfolder of Calendar. I get no error using the following code and get the desired results. Please let us know if we could be of any additional help to you in this regard.

Sample Code:

PersonalStorage pst = PersonalStorage.Create(“TestPst.pst”, FileFormatVersion.Unicode);<o:p></o:p>

FolderInfo fi = pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);

FolderInfo fi2 = fi.AddSubFolder("Calendar2", fi.ContainerClass);

// Create the appointment

MapiCalendar appointment = new MapiCalendar(

"LAKE ARGYLE WA 6743",

"Appointment",

"This is a very important meeting :)",

DateTime.Now,

DateTime.Now.AddDays(1)

);

fi2.AddMapiMessageItem(appointment);

pst.Dispose();


Hi
I tried this code it works fine for me.
But as I need to create different folder hierarchy
I want to add folder which is of type calendar into inbox which is of type mail.
Is it possible?


Thanks & Regards
Amol

Hi Amol,


This is not possible even through Outlook. To observe this, open your Outlook, create a subfolder in Inbox folder, go to its properties and try to change its folder type to Calendar. You will see that Outlook gives an error “You can not create an item of this type in this folder”.

Please let us know if we can be of any additional help to you in this regard.

Hi

Thanks for your immediate reply.

The folder hierarchy which I told (Inbox- - >Calendar) can be created in outlook with no error.

I have added an attachment(inboxcalendar.png) which is screen shot of my pst.

Please let me know if any solution on such hierarchy.

Thanks
Amol Sonawane

Hi Amol,


Please try the following code sample at your end. It should fulfill your requirements:

Sample Code:

PersonalStorage pst = PersonalStorage.Create(“TestPst.pst”, FileFormatVersion.Unicode);<o:p></o:p>

FolderInfo fiInbox = pst.CreatePredefinedFolder("Inbox", StandardIpmFolder.Inbox);

FolderInfo fiCal = fiInbox.AddSubFolder("Cal", "IPF.Appointment");



Thanks for your reply .
Yes it worked for me.