Chuyển đổi MBOX sang PST
Chuyển đổi MBOX sang PST. Chuyển đổi cơ bản
Khi di chuyển dữ liệu thư từ các client như Mozilla Thunderbird sang Microsoft Outlook, việc chuyển đổi kho lưu trữ MBOX sang định dạng PST (Personal Storage Table) thường được yêu cầu. Định dạng PST là định dạng gốc của Outlook và Exchange, hỗ trợ các tính năng nâng cao như cấu trúc thư mục và xử lý tin nhắn dựa trên MAPI.
Aspose.Email cho phép bạn chuyển tin nhắn từ tệp MBOX sang bộ lưu trữ tương thích Outlook với kiểm soát toàn bộ quá trình chuyển đổi. Ví dụ dưới đây tải các tin nhắn từ kho lưu trữ MBOX và lưu chúng vào một tệp dữ liệu Outlook có cấu trúc:
- Khởi tạo trình đọc MBOX với MboxStorageReader.create_reader().
- Tạo một tệp PST với PersonalStorage.create().
- Thêm một thư mục thư điện tử — "Inbox", ví dụ — vào bộ lưu trữ.
- Lặp qua các tin nhắn, chuyển đổi từng tin thành một MapiMessage và chèn nó vào thư mục.
from aspose.email.mapi import MapiMessage
from aspose.email.storage.mbox import MboxStorageReader, MboxLoadOptions
from aspose.email.storage.pst import PersonalStorage, FileFormatVersion, StandardIpmFolder
# Load the source file
mbox = MboxStorageReader.create_reader("source.mbox", MboxLoadOptions())
# Create the destination Outlook data file
with PersonalStorage.create("converted.pst", FileFormatVersion.UNICODE) as personal_storage:
# Add a folder to hold the imported messages
folder_info = personal_storage.create_predefined_folder("Inbox", StandardIpmFolder.INBOX)
# Process each message from the source file
for eml in mbox.enumerate_messages():
msg = MapiMessage.from_mail_message(eml)
folder_info.add_message(msg)
Chuyển đổi MBOX sang PST trong khi Giữ hoặc Loại bỏ Chữ ký
Khi chuyển đổi các tệp MBOX sang định dạng PST, bạn có thể muốn loại bỏ chữ ký số khỏi các tin nhắn để có kết quả sạch hơn hoặc vì mục đích tương thích. Aspose.Email cung cấp một tùy chọn tiện lợi để loại bỏ các chữ ký này trong quá trình chuyển đổi bằng cách sử dụng remove_signature thuộc tính của MboxToPstConversionOptions lớp.
Ví dụ dưới đây minh họa cách kích hoạt tùy chọn này trong dự án Python của bạn:
import aspose.email as ae
personalStorage = ae.storage.pst.PersonalStorage.create("target.pst", ae.storage.pst.FileFormatVersion.UNICODE)
conversion_options = ae.storage.MboxToPstConversionOptions()
conversion_options.remove_signature = True
ae.storage.MailStorageConverter.mbox_to_pst( ae.storage.mbox.MboxrdStorageReader("source.mbox", ae.storage.mbox.MboxLoadOptions()), personalStorage, "Inbox", conversion_options)