MapiCalendarEventRecurrence and PST

I’m in the process of trialing the Aspoe.Email , and posted a couple of questions regarding recurrence appointments, in my case creating them and adding them to a PST file. I’ve encountered another problem, Using the below:

DateTime StartDate = new DateTime(2015, 9, 9, 9, 0, 0);

DateTime endByDate = new DateTime(2015, 9, 30, 9, 5, 0);

MapiCalendar appointment = new MapiCalendar(“Location”, “EndAfterNOccurrencesCHECK”, “Description”, StartDate, endByDate);

MapiCalendarEventRecurrence mapiCalendarEventRecurrence = new MapiCalendarEventRecurrence();

string rrule = string.Format(“DTSTART:{0}\r\nRRULE:{1}”, StartDate.ToString(“yyyyMMdd”), “FREQ=DAILY”);

// Set the Daily recurrence

var rec = new MapiCalendarDailyRecurrencePattern {

PatternType = MapiCalendarRecurrencePatternType.Day,

Period = 1,

WeekStartDay = DayOfWeek.Sunday,

EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences,

OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, rrule, 0),

};

mapiCalendarEventRecurrence.RecurrencePattern = rec;

appointment.Recurrence = mapiCalendarEventRecurrence;

PersonalStorage pst = PersonalStorage.FromFile(pstFileName);

FolderInfo calendarFolder = pst.RootFolder.GetSubFolder(“Calendar”);

calendarFolder.AddMapiMessageItem(appointment);

22 occurrences in total, at present I am having to using DDay.ICal to calculate the number of occurrences as GetOccurrenceCount does not appear to work in the latest build (see other post) However when I ad the item to a pst file it appears to ignore the number of occurrences and the time is incorrect, [screen shot](http://images.devs-on.net/Image/GGQOXfKD7YIYEYez-Region.png) , I’m using build 5.6.0.0

Do you have a downloadable sample projects using all the MapiCalendarEventRecurrence classes that I can trial please? ie adding recurrence items to a PST file? I don’t think I have had any any success as of yet.

Hi Ashley,

I have tested the code by putting the recurrence count = 22 and observed that the output PST contains 22 occurrences only as shown in the attached image. Could you please test the scenario by putting this value and let us know the feedback?

String path = url + "Email_654552";
DateTime StartDate = new DateTime(2015, 9, 9, 9, 0, 0);
DateTime endByDate = new DateTime(2015, 9, 30, 9, 5, 0);

MapiCalendar appointment = new MapiCalendar("Location", "EndAfterNOccurrencesCHECK", "Description", StartDate, endByDate);
MapiCalendarEventRecurrence mapiCalendarEventRecurrence = new MapiCalendarEventRecurrence();

string rrule = string.Format("DTSTART:{0}\r\nRRULE:{1}", StartDate.ToString("yyyyMMdd"), "FREQ=DAILY");

// Set the Daily recurrence
var rec = new MapiCalendarDailyRecurrencePattern
{
    PatternType = MapiCalendarRecurrencePatternType.Day,
    Period = 1,
    WeekStartDay = DayOfWeek.Sunday,
    EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences,
    OccurrenceCount = 22,
};

mapiCalendarEventRecurrence.RecurrencePattern = rec;
appointment.Recurrence = mapiCalendarEventRecurrence;
PersonalStorage pst = PersonalStorage.Create(path + "Output.pst", FileFormatVersion.Unicode);
FolderInfo calendarFolder = pst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments);
calendarFolder.AddMapiMessageItem(appointment);


I am afraid that no complete projects are available. You may refer to Working with Recurrences for more details.

Hi,

Still no success, even with upgrading to 5.7.0.0. [Screen shot](http://images.devs-on.net/Image/oC8NhZ1sE6dqc9fq-Region.png)

Also, here is a video of the output.pst after using the above code. [Video](http://screencast.com/t/dmj7SSMMH26S).

You’ll see that the 22 occurrence count is ignored in outlook and the appointment never ends. When I open the appointment to view the recurrence detail it appears to be correct, when I close and then save it. Then the recurrence rule takes effect,

Hi Ashley,


I have tested the code again and opened the output PST file in Outlook 2013. It contains the 22 occurrences only as shown in the image given above. I am attaching the output PST here for your reference. You may please open it in Outlook 2013 and share the feedback.

Hi,

The output you have attached looks correct.
I have attached a sample project with the demo 5.7.0.0 dll and the sample output from the pst file for you to review?

Can you test this your end and let me know the out come?

Thanks

Hi Ashley,


You are getting this unexpected result because license is not used. You may please use a valid license and thus you will get exact occurrences as expected.

Please feel free to write us back if you have any other query in this regard.