Free Support Forum - aspose.com

Error calculating Yearly Recurrences

Sample code to test:

Private Sub CalculateEndDateV2()
Dim Occurrences As Integer = 22
Dim Pattern As Frequency = Frequency.Yearly
Dim Interval As Integer = 5
Dim StartDate As Date = Date.Now

        Dim startPosition As DayPosition = DayPosition.Third
        Dim startDay As CalendarDay = CalendarDay.Thursday
        Dim startMonth As CalendarMonth = CalendarMonth.March

        Dim recurrencePattern As RecurrencePattern = New YearlyRecurrencePattern() With {
            .Interval = Interval, .Occurs = Occurrences,
            .StartDay = startDay, .StartPosition = startPosition, .StartMonth = startMonth
        }

        Dim ruleStr As String = String.Format("DTSTART:{0}{1}RRULE:{2}", StartDate.ToString("yyyyMMddT000000"), Environment.NewLine, recurrencePattern)
        Dim calendarRecurrence As CalendarRecurrence = CalendarRecurrence.FromiCalendar(ruleStr)
        Dim EndDate As Date = calendarRecurrence.GenerateOccurrences.LastOrDefault
    End Sub

@cyrill.jenni.bw2tech,
Welcome to our community! Thank you for the code snippet. Could you please describe your issue and specify the version of Aspose.Email that you are using?

Subject: Yearly recurrence is not finding all instances
Version: 20.4.0 (Also tested with the latest available 21.1.1)
Description: We are using CalendarRecurrence to get a list of all dates for a given rule but in some cases (Like for example: every 5 years on the third Thursday of March for 22 times) it won’t compute the correct list and we only get the start date. Please review the word file attached.

AsposeEmail_IssueWithYearlyOcurrence.pdf (452.9 KB)

@cyrill.jenni.bw2tech,
Thank you for the issue description. I have logged the issue in our tracking system with ID EMAILNET-40129 for further investigation. You will be notified when it is fixed.

The issues you have found earlier (filed as EMAILNET-40129) have been fixed in this update.