For a calendar event, MapiCalendar.ItemId seems to be empty

Hi @vijaykr
For MonthNth pattern type you can cast the Recurrence.RecurrencePattern to MapiCalendarMonthlyNthRecurrencePattern, then you can access this property.Try the code below.

            MapiCalendar appointment = (MapiCalendar)MapiMessage.Load(msgFileName).ToMapiMessageItem();
            var pattern = appointment.Recurrence.RecurrencePattern as MapiCalendarMonthlyNthRecurrencePattern;
            if(pattern != null)
            {
                DayPosition position = pattern.Position;
            }

Thanks Alexander. I tried to cast the object as you mentioned, but it casts to a null value though appointment.Recurrence.RecurrencePattern.PatternType is “MonthNth”.

var pattern = appointment.Recurrence.RecurrencePattern as MapiCalendarMonthlyNthRecurrencePattern;

Any ideas?

Thanks,
Vijay

Hi @vijaykr

Also you can try to cast RecurrencePattern to MapiCalendarYearlyAndMonthlyRecurrencePattern, which is parent of MapiCalendarMonthlyNthRecurrencePattern and have this property.

Thanks Alexandar. I am able to get the Position property by casting to MapiCalendarYearlyAndMonthlyRecurrencePattern

Thanks for the help.
Vijay

@vijaykr ,

You’re welcome! Thank you for the feedback.

If you have any further questions, feel free to ask.