ניהול חזרות
Aspose.Email תומך ביצירת תבניות חזרה של MAPI לפריטי לוח שנה ומשימות. תבנית משויכת ל recurrence מאפיין של MapiTask או a MapiCalendar אוביקט ונשמר יחד עם הפריט.
המחלקות לתבניות הבאות זמינות:
| מחלקה | מטרה | |——-|———| | MapiCalendarDailyRecurrencePattern | חזרות יומיות | | MapiCalendarWeeklyRecurrencePattern | חזרות שבועיות | | MapiCalendarMonthlyRecurrencePattern | חזרות חודשיות ביום קבוע | | MapiCalendarMonthlyNthRecurrencePattern | חזרות חודשיות ביום השבוע ה-n | | MapiCalendarYearlyAndMonthlyRecurrencePattern | חזרות שנתיות |
כל תבנית תומכת בשלוש סוגי סיום שמסופקות על ידי ה MapiCalendarRecurrenceEndType enumeration:
END_AFTER_N_OCCURRENCES– הסדרה מסתיימת לאחר מספר הנתון של הופעות;END_AFTER_DATE– הסדרה מסתיימת בתאריך הנתון;NEVER_END– הסדרה אינה מסתיימת לעולם.
עבודה עם חזרות יומיומיות
בזה סוג חזרה מספר החזרות נקבע יחד עם המידע האחר:
- קבע את תאריכי ההתחלה וההגשה.
- צור MapiTask.
- הגדר את מצב המשימה ל
NOT_ASSIGNED. - צור את אובייקט החזרה היומי וקבע את ה
pattern_type,period,end_typeוoccurrence_countמאפיינים. - הקצה את אובייקט החזרה ל
recurrenceמאפיין של המשימה. - שמור את הפריט לדיסק.
חזרות יומיומיות עם ספירת אירועים
import datetime
from aspose.email.mapi import (MapiTask, MapiTaskState, MapiCalendarDailyRecurrencePattern,
MapiCalendarRecurrencePatternType, MapiCalendarRecurrenceEndType,
TaskSaveFormat)
start_date = datetime.datetime(2025, 7, 16)
due_date = datetime.datetime(2025, 7, 16)
end_by_date = datetime.datetime(2025, 8, 1)
task = MapiTask("This is test task", "Sample Body", start_date, due_date)
task.state = MapiTaskState.NOT_ASSIGNED
# Set the daily recurrence
recurrence = MapiCalendarDailyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.DAY
recurrence.period = 1
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_N_OCCURRENCES
recurrence.occurrence_count = 5
task.recurrence = recurrence
task.save("Daily_out.msg", TaskSaveFormat.MSG)
חזרות יומיות: סוג סיום END_AFTER_DATE
האפשרות "סיום ב" מושגת על ידי הגדרת ה end_date המאפיין. ה- period מאפיין מגדיר את המרווח — כל יום, כל יום שני, וכן הלאה.
import datetime
from aspose.email.mapi import (MapiCalendarDailyRecurrencePattern, MapiCalendarRecurrencePatternType,
MapiCalendarRecurrenceEndType)
end_by_date = datetime.datetime(2025, 8, 1)
# Every day until the end date
recurrence = MapiCalendarDailyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.DAY
recurrence.period = 1
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_DATE
recurrence.end_date = end_by_date
# Every second day until the end date
recurrence = MapiCalendarDailyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.DAY
recurrence.period = 2
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_DATE
recurrence.end_date = end_by_date
חזרות יומיות: סוג סיום NEVER_END
from aspose.email.mapi import (MapiCalendarDailyRecurrencePattern, MapiCalendarRecurrencePatternType,
MapiCalendarRecurrenceEndType)
recurrence = MapiCalendarDailyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.DAY
recurrence.period = 1
recurrence.end_type = MapiCalendarRecurrenceEndType.NEVER_END
עבודה עם חזרות שבועיות
חזרה שבועית נוצרות עם MapiCalendarWeeklyRecurrencePattern. הימים בשבוע נבחרים דרך ה day_of_week מאפיין באמצעות ערכי ה MapiCalendarDayOfWeek מניית דגלים, שניתן לשלב עם ה | אופרטור.
חזרות שבועיות: סוג סיום END_AFTER_N_OCCURRENCES
import datetime
from aspose.email.mapi import (MapiTask, MapiTaskState, MapiCalendarWeeklyRecurrencePattern,
MapiCalendarRecurrencePatternType, MapiCalendarRecurrenceEndType,
MapiCalendarDayOfWeek, TaskSaveFormat)
start_date = datetime.datetime(2025, 7, 16)
due_date = datetime.datetime(2025, 7, 16)
end_by_date = datetime.datetime(2025, 9, 1)
task = MapiTask("This is test task", "Sample Body", start_date, due_date)
task.state = MapiTaskState.NOT_ASSIGNED
recurrence = MapiCalendarWeeklyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.WEEK
recurrence.period = 1
recurrence.day_of_week = MapiCalendarDayOfWeek.FRIDAY
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_N_OCCURRENCES
recurrence.occurrence_count = 7
task.recurrence = recurrence
task.save("Weekly_out.msg", TaskSaveFormat.MSG)
בחירת מספר ימים בשבוע והגדרת מרווחים
from aspose.email.mapi import (MapiCalendarWeeklyRecurrencePattern, MapiCalendarRecurrencePatternType,
MapiCalendarRecurrenceEndType, MapiCalendarDayOfWeek)
recurrence = MapiCalendarWeeklyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.WEEK
recurrence.period = 2
recurrence.day_of_week = MapiCalendarDayOfWeek.FRIDAY | MapiCalendarDayOfWeek.MONDAY
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_N_OCCURRENCES
recurrence.occurrence_count = 10
חזרות שבועיות: סוגי סיום END_AFTER_DATE ו‑NEVER_END
import datetime
from aspose.email.mapi import (MapiCalendarWeeklyRecurrencePattern, MapiCalendarRecurrencePatternType,
MapiCalendarRecurrenceEndType, MapiCalendarDayOfWeek)
end_by_date = datetime.datetime(2025, 9, 1)
# End by a given date
recurrence = MapiCalendarWeeklyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.WEEK
recurrence.period = 1
recurrence.day_of_week = MapiCalendarDayOfWeek.FRIDAY
recurrence.end_type = MapiCalendarRecurrenceEndType.END_AFTER_DATE
recurrence.end_date = end_by_date
# Never end
recurrence = MapiCalendarWeeklyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.WEEK
recurrence.period = 1
recurrence.day_of_week = MapiCalendarDayOfWeek.FRIDAY
recurrence.end_type = MapiCalendarRecurrenceEndType.NEVER_END
עבודה עם חזרות חודשיות
חזרה חודשית ביום קבוע של החודש נוצרה באמצעות MapiCalendarMonthlyRecurrencePattern ועמו day מאפיין:
import datetime
from aspose.email.mapi import (MapiTask, MapiCalendarMonthlyRecurrencePattern,
MapiCalendarRecurrencePatternType, MapiCalendarRecurrenceEndType,
TaskSaveFormat)
start_date = datetime.datetime(2025, 7, 16)
due_date = datetime.datetime(2025, 7, 16)
task = MapiTask("This is test task", "Sample Body", start_date, due_date)
recurrence = MapiCalendarMonthlyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.MONTH
recurrence.period = 1
recurrence.day = 16
recurrence.end_type = MapiCalendarRecurrenceEndType.NEVER_END
task.recurrence = recurrence
task.save("Monthly_out.msg", TaskSaveFormat.MSG)
כדי לחזור על היום השבועי של חודש — לדוגמה יום שלישי השני — השתמש ב‑ MapiCalendarMonthlyNthRecurrencePattern עם ה‑ day_of_week ו position מאפיינים. המיקום הוא ערך של DayPosition הצאות — FIRST, SECOND, THIRD, FOURTH או LAST:
from aspose.email.mapi import (MapiCalendarMonthlyNthRecurrencePattern, MapiCalendarRecurrencePatternType,
MapiCalendarRecurrenceEndType, MapiCalendarDayOfWeek)
from aspose.email.calendar.recurrences import DayPosition
recurrence = MapiCalendarMonthlyNthRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.MONTH_NTH
recurrence.period = 1
recurrence.day_of_week = MapiCalendarDayOfWeek.TUESDAY
recurrence.position = DayPosition.SECOND
recurrence.end_type = MapiCalendarRecurrenceEndType.NEVER_END
עבודה עם חזרות שנתיות
חזרות שנתיות נוצרות באמצעות MapiCalendarYearlyAndMonthlyRecurrencePattern. תקופה שנתית מובעת כ‑12 חודשים:
import datetime
from aspose.email.mapi import (MapiTask, MapiCalendarYearlyAndMonthlyRecurrencePattern,
MapiCalendarRecurrencePatternType, MapiCalendarRecurrenceEndType,
TaskSaveFormat)
start_date = datetime.datetime(2025, 7, 16)
due_date = datetime.datetime(2025, 7, 16)
task = MapiTask("This is test task", "Sample Body", start_date, due_date)
recurrence = MapiCalendarYearlyAndMonthlyRecurrencePattern()
recurrence.pattern_type = MapiCalendarRecurrencePatternType.MONTH
recurrence.period = 12
recurrence.day = 16
recurrence.end_type = MapiCalendarRecurrenceEndType.NEVER_END
task.recurrence = recurrence
task.save("Yearly_out.msg", TaskSaveFormat.MSG)
WeekStartDay מאפיין ש‑Aspose.Email עבור .NET מציגה על תבניות החזרה אינו זמין ב‑Aspose.Email עבור Python דרך .NET. היום שבו מתחיל השבוע הוא ברירת המחדל של הערך המשמש על ידי סוג התבנית.
ראייה נוספת
- ניהול פריטי לוח השנה של Outlook — יצירה, שמירה וקריאת פריטי לוח שנה של MAPI.
- ניהול משימות Outlook — יצירה וקריאת משימות MAPI.