Thanks Margarita.
I am trying to validate that I am able to get all the calendar data from the code I have written. To do this validation, I opened the pst file in Outlook directly and tried to scan through the calendar data that shows on Outlook and did a spot check to see if those are showing up on the data I am pulling from code. It appears like though there are some calendar events that are getting pulled up but appears like most calendar items are not. Can you scan through the logic I have and let me know what could be going wrong?
PersonalStorage personalStorage = PersonalStorage.FromFile(pstFilePath);
FolderInfo folderInfo = personalStorage.RootFolder;
MessageInfoCollection messages = folderInfo.GetContents();
foreach (MessageInfo messageInfo in messages)
{
MapiMessage message = personalStorage.ExtractMessage(messageInfo);
{
if (message.MessageClass == “IPM.Appointment”)
{
var calEvent = message.ToMapiMessageItem() as MapiCalendar;
/* Add the needed info to logs */
}
}
}
With the code above, I am getting about 50 of the calendar events. But when looking from Outlook calendar directly, there are 1000s of events that I have in the calendar.
I tried to log the folder name and message count in that folder through a console log.
Console.WriteLine("Folder: " + folderInfo.DisplayName + ", Message Count: " + messages.Count);
For Calendar folder, I get this:
Folder: Calendar, Message Count: 50
A bunch of other folders are also showing the message count as 50.
Folder: United States holidays, Message Count: 50
Folder: Contacts, Message Count: 50
I know there are more than 50 contacts for sure. Something isn’t correct. Across all the folders that are getting read, the max I items I am seeing under every folder is 50 and not more than that. (a lot of them have less than 50 but 50 is the max for some reason). I check Sent Items mail count as well and that is coming out to be 50 too.
Folder: Sent Items, Message Count: 50
What do I need to do to ensure I am not missing out on any events? And why aren’t all the events in the calendar getting picked up with the above code and only some are coming through? I am hoping all the events in a calendar are of type IPM.Appointment. [BTW I also tried to pull IPM.Schedule.meeting items but there are none. So my guess is IPM.Appointment is the right way to pull the calendar events].
Any suggestions on what would be the best way to validate that the code is pulling all the events and not missing any?
Thanks,
Vijay