Python을 사용해 MBOX 파일에서 필터링된 메시지 가져오기

제목 및 날짜별 MBOX 메시지 필터링

Aspose.Email for Python via .NET는 쿼리를 사용하여 MBOX 파일 내의 메시지를 필터링하거나 검색할 수 있는 기능을 제공합니다. 다음 메서드를 사용하면 특정 기준에 일치하는 메시지만 검색할 수 있습니다:

아래 코드 샘플은 메시지 필터링에서 이러한 메서드를 사용하는 방법을 보여줍니다:

import datetime
from aspose.email.storage.mbox import MboxStorageReader, MboxLoadOptions
from aspose.email import MailQueryBuilder

# Create an MBOX reader with load options
reader = MboxStorageReader.create_reader("input.mbox", MboxLoadOptions())

# Build the mail query
mqb = MailQueryBuilder()
mqb.subject.contains("Project Update")
mqb.sent_date.before(datetime.date.today())

# Iterate over matching messages
for message in reader.enumerate_messages(mqb.get_query()):
    print("Subject:", message.subject)

MBOX 메시지의 페이지 매김 검색

Python용 Aspose.Email via .NET은 MBOX 파일의 페이지별 읽기를 지원하여 대용량 이메일 아카이브를 효율적으로 처리할 수 있게 합니다. 전체 메시지 세트를 메모리에 로드하는 대신, 더 작고 관리 가능한 배치로 메시지를 가져올 수 있습니다. 이는 특히 매우 큰 아카이브 파일을 다룰 때 메모리 사용량을 줄이고 처리 성능을 향상시키는 데 유용합니다.

다음 메서드를 사용하여 페이지별 MBOX 메시지를 조회할 수 있습니다:

다음 코드 샘플은 Aspose.Email 라이브러리를 사용하여 MBOX 파일에서 메시지를 읽고 관리 가능한 청크로 가져오는 방법을 보여줍니다:

from aspose.email.storage.mbox import MboxStorageReader, MboxLoadOptions

# Initialize MBOX reader with load options
reader = MboxStorageReader.create_reader("input.mbox", MboxLoadOptions())

# Define pagination parameters
start_index = 0
count = 10  # Retrieve messages in batches of 10

# Enumerate and display messages in the current batch
for message in reader.enumerate_messages(start_index, count):
    print("Subject:", message.subject)