Relative Yearly Recurrence Pattern

Hi,

How can I create recurrency that taking place yearly on Saturday of the 3’rd week of January ?

Thanks

Hi,


You may please use following sample code to generate the required recurrence pattern and share the feedback.

<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>public static void
MapiCalendar_ThirdSaturdayOfJanuary_Email_708193()

{

MapiCalendar mapiMonthly =
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>null
;

java.util.Calendar calendar =
java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“GMT”
));



calendar.set(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>2017, java.util.Calendar.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>JANUARY
, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>1, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);



Date startDate = calendar.getTime();



calendar.set(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>2017, java.util.Calendar.JANUARY, 1, 0, 0, 0);




Date endDate = calendar.getTime();



<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>try

{

MapiCalendar cal =
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
MapiCalendar();

cal.setLocation(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Location”
);

cal.setSubject(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Subject”
);

cal.setBody(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Description”
);

cal.setStartDate(startDate);

<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:gray”>// Set the yearly recurrence

MapiCalendarMonthlyNthRecurrencePattern rec = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
MapiCalendarMonthlyNthRecurrencePattern();

rec.setEndType(MapiCalendarRecurrenceEndType.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>NeverEnd
);

rec.setOccurrenceCount(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);

rec.setPatternType(MapiCalendarRecurrencePatternType.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>MonthNth
);

rec.setPeriod(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>12);

rec.setWeekStartDay(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);

rec.setDayOfWeek(MapiCalendarDayOfWeek.
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>Saturday
);

rec.setPosition(DayPosition.
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>Third
);


cal.getRecurrence().setRecurrencePattern(rec);

cal.save(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“ThirdSaturdayOfJanuary.msg”
, AppointmentSaveFormat.<span style=“font-size:9.0pt;
font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>Msg
);

}

<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>catch
(Exception ex)

{

System.
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out
.println(ex.getMessage());

}

}

Hi,

Thanks, your sample is working.
Now I have another issue.
I’m trying to create a task with monthly recurring pattern and where start day is April 13 and complete day and due day is April 14 and getting this exception :

class com.aspose.email.system.exceptions.ArgumentException: The start date should be less than the date completed.

com.aspose.email.MapiTask.b(SourceFile:557)

com.aspose.email.MapiTask.i(SourceFile:1416)

com.aspose.email.MapiTask.setRecurrence(SourceFile:691)


Please advise.

Thanks

Hi,


I have tried to re-produce the scenario but no issue is observed. Could you please give a try to the following sample code and share your feedback?

<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>public static void
Email_711545()

{

java.util.Calendar calendar =
java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“GMT”
));

calendar.set(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>2016, Calendar.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>APRIL
, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>13, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);

Date startDate = calendar.getTime();

calendar.set(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>2016, java.util.Calendar.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>APRIL
, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>14, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0, <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);

Date dueDate = calendar.getTime();

MapiTask task =
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
MapiTask(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“This is a test task”
,<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“Sample Body”
, startDate,dueDate);

MapiCalendarMonthlyRecurrencePattern
rec =
<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy”>new
MapiCalendarMonthlyRecurrencePattern();

rec.setDay(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>13);

rec.setPeriod(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>1);

rec.setPatternType(MapiCalendarRecurrencePatternType.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>Month
);

rec.setEndType(MapiCalendarRecurrenceEndType.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>NeverEnd
);

task.setRecurrence(rec);

task.save(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Monthly.msg”
,TaskSaveFormat.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>Msg
);

}

Hi,

Made some small modification to your code , now it’s reproduce the issue. This data is coming from Microsoft Office 365 customer account, so it’s a real data.

java.util.Calendar calendar = java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone(“GMT”));

calendar.set(2016, Calendar.APRIL, 13, 4, 0, 0);

Date startDate = calendar.getTime();

calendar.set(2016, java.util.Calendar.APRIL, 14, 4, 0, 0);

Date dueDate = calendar.getTime();

MapiTask task1 = new MapiTask(“This is a test task”,“Sample Body”, startDate,dueDate);

MapiCalendarMonthlyRecurrencePattern rec = new MapiCalendarMonthlyRecurrencePattern();

rec.setDay(15);

rec.setPeriod(1);

rec.setPatternType(MapiCalendarRecurrencePatternType.Month);

rec.setEndType(MapiCalendarRecurrenceEndType.NeverEnd);

task1.setDateCompleted(calendar.getTime());

task1.setStatus(MapiTaskStatus.Complete);

task1.setRecurrence(rec);

task1.save(“Monthly.msg”,TaskSaveFormat.Msg);

Hi,


Thank you for providing detailed sample code.

This issue is re-produced here and logged under Id: EMAILJAVA-33582 for further investigation by the product team. You will be notified once any update is received in this regard.

Hi,

Is there any reason I stopped to get any updated from your system about bug fixes and new versions ?
And specially about this bug ?
Thanks

Hi,

We are sorry for the inconvenience caused to you.

The thread was somehow de-linked from the logged ticket and that is why you couldn’t receive the notification about the fix version. Please download the latest version of Aspose.Email for Java 6.5.0 that contains the fix for this issue.