PST 파일에서 캘린더 항목 관리

PST 파일에 캘린더 이벤트 추가

새 PST 파일 만들기 및 서브 폴더 추가 PST 파일을 생성하고 서브 폴더를 포함하는 방법을 보여줍니다. Aspose.Email을 사용하면 기존 또는 새로 만든 PST 파일의 Calendar 서브 폴더에 MapiCalendar를 추가할 수도 있습니다. 아래는 PST 파일에 MapiCalendar를 추가하는 단계입니다:

  1. 다음을 생성합니다 MapiCalendar 객체.
  2. 생성자와 메서드를 사용하여 MapiCalendar 속성을 설정합니다.
  3. 다음을 사용하여 PST를 생성합니다 PersonalStorage.create() 메서드.
  4. 루트 폴더에 접근한 후 add_mapi_message_item() 메서드를 호출하여 PST 파일 루트에 사전 정의된 폴더(캘린더)를 생성합니다.

다음 코드 스니펫은 MapiCalendar를 생성하고 이를 새롭게 만든 PST 파일의 캘린더 폴더에 추가하는 방법을 보여줍니다:

Outlook 캘린더 항목을 ICS 파일로 저장

이 문서는 Outlook PST 파일에서 캘린더 항목에 접근하고 이를 디스크에 ICS 형식으로 저장하는 방법을 설명합니다. 다음을 사용해야 합니다 the PersonalStorageMapiCalendar 클래스를 사용하여 캘린더 데이터를 가져옵니다. 캘린더 항목을 저장하기 위한 단계는 다음과 같습니다:

  1. 다음 방법을 사용해 PST 파일을 로드합니다 the PersonalStorage 클래스.
  2. 캘린더 폴더로 이동합니다.
  3. 캘린더 폴더에서 메시지 컬렉션을 가져옵니다.
  4. 메시지 컬렉션을 반복합니다.
  5. 다음 사용 PersonalStorage.extract_message() 연락처 정보를 얻는 메서드 in the MapiCalendar 클래스.
  6. 다음 사용 MapiCalendar.save() 각 캘린더 항목을 디스크에 ICS 형식으로 저장하는 메서드.

아래 프로그램은 디스크에서 PST 파일을 로드하고 모든 캘린더 항목을 ICS 형식으로 저장합니다. 이러한 ICS 파일은 표준 ICS 캘린더 파일을 지원하는 다른 프로그램에서도 사용할 수 있습니다. Microsoft Outlook에서 열면 아래 스크린샷과 같이 표시됩니다.

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 파일에서 반복 발생 수정 또는 삭제

Aspose.Email for .NET API를 사용하여 PST 파일에서 기존 반복 패턴에 예외를 추가하거나 특정 발생을 삭제할 수 있습니다. 다음 코드 예제는 이러한 수정 방법을 보여줍니다:

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)