کار با فایلهای PST بزرگ
Contents
[
Hide
]
عملکرد ممکن است هنگام پردازش فایلهای PST بزرگ کاهش یابد. راهحلهای زیر به شما کمک میکند تا عملکرد برنامه خود را هنگام پردازش فایلهای ذخیرهسازی بزرگ بهبود بخشید.
در زمان پیمایش پوشهها یا پیامهای یک PST، روشهای شمارش را ترجیح دهید.
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for message_info in folder.enumerate_messages():
# Do something with the message
print(message_info.subject)
ترجیحاً MessageInfo برای دسترسی به ویژگیهای پایه پیام.
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for message_info in folder.enumerate_messages():
print(f"Subject: {message_info.subject}")
print(f"To: {message_info.display_to}")
print(f"Importance: {message_info.importance}")
print(f"Message Class: {message_info.message_class}")
از فراخوانی خودداری کنید
extract_message یا enumerate_mapi_messages برای تمام پیامها مگر اینکه به تمام ویژگیهای آنها دسترسی لازم داشته باشید.
از استفاده کردن فکر کنید
enumerate_messages_entry_id برای بازیابی تمام شناسههای پیام موجود در یک پوشه.
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for entry_id in folder.enumerate_messages_entry_id():
# Use the id to retrieve a single property (extract_property),
# extract a MapiMessage (extract_message),
# extract the message attachments (extract_attachments),
# or save the message to a stream (save_message_to_stream).
pass
از استفاده کردن فکر کنید
extract_property برای خواندن یک ویژگی که در MessageInfo.
import base64
from aspose.email.mapi import KnownPropertyList
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for msg_id in folder.enumerate_messages_entry_id():
transport_message_headers = pst.extract_property(
base64.b64decode(msg_id),
KnownPropertyList.TRANSPORT_MESSAGE_HEADERS.tag)
از استفاده کردن فکر کنید
extract_attachments اگر فقط پیوستها مورد نیاز هستند.
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for msg_id in folder.enumerate_messages_entry_id():
attachments = pst.extract_attachments(msg_id)
استفاده کنید فیلترنگذاری بر پایه جستجو وجود ندارد، برای دریافت تنها پیامهای موردنیاز استفاده کنید.
from aspose.email.mapi import MapiMessageFlags
from aspose.email.storage.pst import PersonalStorage, PersonalStorageQueryBuilder
with PersonalStorage.from_file("storage.pst") as pst:
builder = PersonalStorageQueryBuilder()
# Unread messages
builder.has_no_flags(MapiMessageFlags.READ)
for folder in pst.root_folder.enumerate_folders():
unread = folder.get_contents(builder.get_query())
از استفاده کردن فکر کنید
save_message_to_stream زمانی که لازم است پیامها را از یک PST ذخیره کنید.
به جای استفاده از:
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for entry_id in folder.enumerate_messages_entry_id():
msg = pst.extract_message(entry_id)
msg.save("message.msg")
از استفاده کنید:
from aspose.email.storage.pst import PersonalStorage
with PersonalStorage.from_file("storage.pst") as pst:
for folder in pst.root_folder.enumerate_folders():
for entry_id in folder.enumerate_messages_entry_id():
with open("message.msg", "wb") as stream:
pst.save_message_to_stream(entry_id, stream)
Aspose.Email برای .NET بهعلاوه عملیات PST بهصورت غیرهمزمان را ارائه میدهد —
CreateAsync, FromFileAsync, MergeWithAsync و SplitIntoAsync. این روشها بر پایه .NET tasks و توکنهای لغو هستند و در Aspose.Email برای Python از طریق .NET نمایش داده نمیشوند؛ بهجای آنها از همتاهای همزمان استفاده کنید.