Last active
April 22, 2024 15:48
-
-
Save aspose-com-gists/1dbac77d1d7eb9df7f20f2091c19db50 to your computer and use it in GitHub Desktop.
Create PST Files in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a PST file | |
with PersonalStorage.create("sample.pst", FileFormatVersion.UNICODE) as pst: | |
# Access the folder to add items | |
inbox_folder = pst.root_folder.get_sub_folder("Inbox") | |
# Create a new message | |
message = MapiMessage("from@example.com", "to@example.com", "Subject", "Body") | |
# Add the message to the Inbox folder | |
inbox_folder.add_message(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a PST file | |
with PersonalStorage.create("sample.pst", FileFormatVersion.UNICODE) as pst: | |
# Create a standard folder (Contacts) | |
contacts_folder = pst.create_predefined_folder("My Contacts", StandardIpmFolder.CONTACTS) | |
# Load a contact from vcf file | |
contact = MapiContact.from_v_card("Contact.vcf") | |
# Add the contact to the folder | |
contacts_folder.add_mapi_message_item(contact) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a PST file | |
with PersonalStorage.create("sample.pst", FileFormatVersion.UNICODE) as pst: | |
# Create a custom folder | |
some_folder = pst.root_folder.add_sub_folder("SomeFolder") | |
# Create a subfolder to the custom folder | |
sub_folder = some_folder.add_sub_folder("SubFolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inbox_folder = pst.create_predefined_folder("Inbox", PersonalStorage.StandardIpmFolder.INBOX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pst_path = "output.pst" | |
pst = PersonalStorage.create(pst_path, PersonalStorage.UNICODE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment