손상된 PST/OST 파일 읽기
Contents
[
Hide
]
손상된 PST/OST 파일 읽기
일부 경우에는 PST 또는 OST 파일이 손상이나 손상으로 인해 접근할 수 없게 될 수 있습니다. 이때 Outlook이 파일을 열지 못해 중요한 이메일 및 기타 메일함 데이터를 가져오기 어려워집니다.
Aspose.Email은 메시지 및 폴더 ID를 사용하여 손상된 PST 파일에서 손상되지 않은 메시지를 스캔하고 추출할 수 있는 API를 제공합니다.
다음 메서드는 PersonalStorage 클래스는 손상된 PST 파일에서 데이터를 복구하는 데 필수적입니다:
-
메시지 및 폴더 ID 가져오기:
find_messages(parent_entry_id) - 지정된 폴더 내의 메시지 ID 목록을 가져옵니다.
find_subfolders(parent_entry_id) - 지정된 폴더 내의 하위 폴더 ID 목록을 가져옵니다.
-
ID를 사용하여 메시지 및 폴더에 접근하기:
extract_message(entry_id) - 엔트리 ID를 사용하여 PST 파일에서 메시지를 추출합니다.
get_folder_by_id(entry_id) - 엔트리 ID를 사용하여 PST 파일에서 폴더를 가져옵니다.
다음 코드 예제는 잠재적으로 손상된 PST 파일을 탐색하고, 손상되지 않은 메시지를 추출하며, 하위 폴더를 탐색하는 방법을 보여줍니다:
import aspose.email as ae
def explore_corrupted_pst(pst, root_folder_id):
message_id_list = pst.find_messages(root_folder_id)
for message_id in message_id_list:
try:
msg = pst.extract_message(message_id)
print("- " + msg.subject)
except Exception as e:
print("Message reading error. Entry id: " + message_id)
folder_id_list = pst.find_subfolders(root_folder_id)
for sub_folder_id in folder_id_list:
if sub_folder_id != root_folder_id:
try:
subfolder = pst.get_folder_by_id(sub_folder_id)
print(subfolder.display_name)
except Exception as e:
print("Message reading error. Entry id: " + sub_folder_id)
explore_corrupted_pst(pst, sub_folder_id)
pst = ae.storage.pst.PersonalStorage.from_file("target.pst")
explore_corrupted_pst(pst, pst.root_folder.entry_id_string)