Consider the following recurrence pattern.
1.PNG (29.3 KB)
The recurrence is a monthly one and starts at 12:00 am 17th and ends at 2:30 am 19th. The recurrence pattern starts on Oct 2019 and ends by Jul 2020.
The following code has been used to create an appointment with this type for recurrence.
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getDefault());
Date fromTime = dateFormat.parse("17-10-2019 12:00:00"), toTime = dateFormat.parse("19-10-2019 02:30:00");
MapiCalendar mapiCalendar = new MapiCalendar();
MailAddressCollection mailAddressCollection = new MailAddressCollection();
mailAddressCollection.addItem(new MailAddress("abc@abc.com", "abc"));
Appointment appointment = new Appointment("", fromTime, toTime, new MailAddress("abc@abc.com", "abc"), mailAddressCollection);
MailMessage msg = new MailMessage();
msg.addAlternateView(appointment.requestApointment());
MapiMessage mapi = MapiMessage.fromMailMessage(msg);
mapiCalendar = (MapiCalendar) mapi.toMapiMessageItem();
mapiCalendar.setAllDay(false);
mapiCalendar.setAppointmentCounterProposal(false);
mapiCalendar.setBusyStatus(MapiCalendarBusyStatus.Free);
mapiCalendar.setClientIntent(0);
mapiCalendar.setReminderDelta(1080);
mapiCalendar.setReminderSet(true);
MapiCalendarRecurrencePattern recurrencePattern = new MapiCalendarYearlyAndMonthlyRecurrencePattern();
recurrencePattern.setPatternType(MapiCalendarRecurrencePatternType.Month);
recurrencePattern.setCalendarType(MapiCalendarRecurrenceCalendarType.Default);
recurrencePattern.setPeriod(1);
recurrencePattern.setEndType(MapiCalendarRecurrenceEndType.NeverEnd);
recurrencePattern.setSlidingFlag(false);
((MapiCalendarYearlyAndMonthlyRecurrencePattern)recurrencePattern).setDay(17);
recurrencePattern.setEndType(MapiCalendarRecurrenceEndType.EndAfterDate);
recurrencePattern.setOccurrenceCount(10);
recurrencePattern.setWeekStartDay(0);
recurrencePattern.setStartDate(dateFormat.parse("17-10-2019 00:00:00"));
recurrencePattern.setEndDate(dateFormat.parse("19-07-2020 02:30:00"));
MapiCalendarEventRecurrence mapiCalendarEventRecurrence = new MapiCalendarEventRecurrence();
mapiCalendarEventRecurrence.setRecurrencePattern(recurrencePattern);
mapiCalendarEventRecurrence.setClipStart(dateFormat.parse("17-10-2019 00:00:00"));
mapiCalendarEventRecurrence.setClipEnd(dateFormat.parse("17-07-2020 00:00:00"));
mapiCalendar.setRecurrence(mapiCalendarEventRecurrence);
mapiCalendar.setBodyContent("<DIV STYLE=\"text-align:Left;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:12;color:#000000;\"><P STYLE=\"font-family:Calibri;font-size:14.666666666666666;margin:0 0 0 0;\"><SPAN><SPAN>test</SPAN></SPAN></P></DIV>", 2);
mapiCalendar.setSubject("test recurring event");
But this code ended up creating an item with this recurrence.
2.PNG (29.5 KB)
PFA. Test3.zip (1.2 KB)
Please assist on where I went wrong.