ניהול פריטי יומן בקבצי PST

הוסף אירועי יומן לקבצי PST

צור קובץ PST חדש והוסף תתי‑תיקיות הדגים כיצד ליצור קובץ PST ולהוסיף תתי‑תיקיות בתוכו. עם Aspose.Email ניתן גם להוסיף MapiCalendar לתיקיית Calendar של קובץ PST קיים או חדש שנוצר. להלן הצעדים להוספת MapiCalendar לקובץ PST:

  1. צור MapiCalendar אובייקט.
  2. הגדר את תכונות MapiCalendar באמצעות בנאי ומתודות.
  3. צור PST באמצעות ה‑ PersonalStorage.create() שיטה.
  4. צור תיקייה מוגדרת מראש (Calendar) בשורש קובץ PST על‑ידי גישה לתיקיית השורש ולאחר כך קריאה לשיטה add_mapi_message_item().

קטע הקוד הבא מראה כיצד ליצור MapiCalendar ולאחר מכן להוסיף אותו לתיקיית היומן של קובץ PST שנוצר חדש:

שמור פריטי יומן של Outlook קבצי ICS

מאמר זה מסביר כיצד לגשת לפריטי יומן מקובץ PST של Outlook ולשמור אותם לדיסק בפורמט ICS. תצטרך להשתמש ב‑ PersonalStorage ו MapiCalendar מחלקות כדי לשלוף את נתוני היומן. עקוב אחרי הצעדים הבאים כדי לשמור פריטי יומן:

  1. טען את קובץ PST באמצעות ה‑ PersonalStorage מחלקה.
  2. נווט לתיקיית Calendar.
  3. קבל את אוסף ההודעות מתיקיית Calendar.
  4. עבור על איסוף ההודעות.
  5. השתמש ב- PersonalStorage.extract_message() שיטה לקבל מידע איש קשר ב‑ MapiCalendar מחלקה.
  6. השתמש ב- MapiCalendar.save() שיטה לשמור כל פריט יומן לדיסק בפורמט ICS.

התוכנית למטה טוענת קובץ PST מהדיסק ושומרת את כל פריטי היומן בפורמט ICS. קבצי ICS אלה ניתנים לשימוש בכל תוכנה תומכת בקבצי יומן סטנדרטיים של ICS. כאשר נפתחים ב‑Microsoft Outlook, קובץ ICS מופיע כמתואר בתצלום המסך שלהלן.

todo:image_alt_text

קטע הקוד הבא מדגים כיצד לייצא פריטי יומן מ‑Outlook PST לפורמט ICS:

שמר קובצי ICS עם חותמות זמן מקוריות

מתודת keep_original_date_time_stamp של MapiCalendarIcsSaveOptions מחלקה מאפשרת לשמור על חותמות התאריך והשעה המקוריות של פריטי היומן בעת שמירתם כקובץ ICS (iCalendar). דוגמת הקוד הבאה מציגה את מימוש המתודה הזו:

import aspose.email as ae

pst = ae.storage.pst.PersonalStorage.from_file("my.pst")

calendar_folder = pst.get_predefined_folder(ae.storage.pst.StandardIpmFolder.APPOINTMENTS)

for msg_info in calendar_folder.enumerate_messages():
    cal = pst.extract_message(msg_info).to_mapi_message_item()

    save_options = ae.mapi.MapiCalendarIcsSaveOptions()
    save_options.keep_original_date_time_stamp = True

    if not (cal is None):
      cal.save("cal.ics", save_options)

שנה או מחק אירועי חזרה בקבצי PST

אתה יכול להוסיף חריגים לתבניות חזרתיות קיימות או למחוק אירועים ספציפיים בקבצי PST באמצעות Aspose.Email עבור .NET API. דוגמת הקוד הבאה מדגימה כיצד לבצע שינויים כאלה:

from datetime import datetime, timedelta
from aspose.email.storage.pst import PersonalStorage, StandardIpmFolder, FileFormatVersion
from aspose.email.mapi import MapiCalendar, MapiCalendarEventRecurrence, \
    MapiCalendarDailyRecurrencePattern, MapiCalendarRecurrenceEndType, \
    MapiCalendarExceptionInfo, MapiCalendarRecurrencePatternType, \
    MapiRecipientCollection, MapiRecipientType

start_date = datetime.now().date()

recurrence = MapiCalendarEventRecurrence()
pattern = MapiCalendarDailyRecurrencePattern()
pattern.pattern_type = MapiCalendarRecurrencePatternType.DAY
pattern.period = 1
pattern.end_type = MapiCalendarRecurrenceEndType.NEVER_END
recurrence.recurrence_pattern = pattern

exception_date = start_date + timedelta(days=1)

# adding one exception
exception_info = MapiCalendarExceptionInfo()
exception_info.location = "London"
exception_info.subject = "Subj"
exception_info.original_start_date = exception_date
exception_info.start_date_time = exception_date
exception_info.end_date_time = exception_date + timedelta(hours=5)
pattern.exceptions.append(exception_info)
pattern.modified_instance_dates.append(exception_date)
# every modified instance also has to have an entry in the DeletedInstanceDates field with the original instance date.
pattern.deleted_instance_dates.append(exception_date)

# adding one deleted instance
pattern.deleted_instance_dates.append(exception_date + timedelta(days=2))

rec_coll = MapiRecipientCollection()
rec_coll.add("receiver@domain.com", "receiver", MapiRecipientType.TO)
new_cal = MapiCalendar(
    "This is Location",
    "This is Summary",
    "This is recurrence test",
    start_date,
    start_date + timedelta(hours=3),
    "organizer@domain.com",
    rec_coll
)
new_cal.recurrence = recurrence

with PersonalStorage.create("output.pst", FileFormatVersion.UNICODE) as pst:
    calendar_folder = pst.create_predefined_folder("Calendar", StandardIpmFolder.APPOINTMENTS)
    calendar_folder.add_message(new_cal)