Thunderbird MBOX 파일에 메시지 쓰기

Contents
[ ]

프로그램matically 새 메시지를 Thunderbird 메일 저장 파일에 추가해야 하는 경우, Aspose.Email은 다음을 제공합니다 MboxrdStorageWriter 이 작업을 단순화하는 클래스입니다. 이 클래스를 사용하면 기존 MBOX 파일에 메시지를 쓸 수 있습니다.

아래 단계에서는 사용 방법을 설명합니다 MboxrdStorageWriter 와 함께 MailMessage Thunderbird 메일 형식으로 메시지를 생성하고 저장하는 클래스입니다. 프로세스를 보여주는 코드 샘플도 제공됩니다.

  1. 다음의 인스턴스를 생성합니다. MboxrdStorageWriter 클래스, Thunderbird 저장소 파일 경로와 MboxSaveOptions 객체를 생성자에 전달합니다.
  2. 다음을 사용하여 새 메시지를 준비합니다. MailMessage 클래스.
  3. 다음을 호출합니다. write_message() method에 전달하고 MailMessage 인스턴스를 사용해 메시지를 Thunderbird 저장소에 추가합니다.
  4. 작가(writer)를 컨텍스트 관리자처럼 사용합니다 (the with 문(statement)으로 파일 쓰기가 끝나면 파일이 닫히도록 합니다.
import aspose.email as ae
from aspose.email.storage.mbox import MboxrdStorageWriter, MboxSaveOptions

with MboxrdStorageWriter(data_dir + "ExampleMBox_out.mbox", MboxSaveOptions()) as writer:
    # Prepare a new message using the MailMessage class
    message = ae.MailMessage("from@domain.com", "to@domain.com",
                             "EML generated for MBOX",
                             "Added with Aspose.Email for Python via .NET")
    message.is_draft = False

    # Add the message to the storage
    writer.write_message(message)