Error when dispose() a pst file

Hi! I’m trying to run the official sample code but the dispose() method doesn’t exist. What am I doing wrong?

# python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from aspose.email.storage.pst import *
>>> from aspose.email.mapi import MapiMessage
>>> pst = PersonalStorage.create("test.pst", FileFormatVersion.UNICODE)
>>> inboxFolder = pst.root_folder.add_sub_folder("Inbox");
>>> inboxFolder.add_message(MapiMessage.from_file("aaaaa.msg"))
'AAAAAIAjapG9oY1IpV8ciXc8ZtwkACAA'
>>> pst.dispose()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'aspose.email.storage.pst.PersonalStorage' object has no attribute 'dispose'

Thank you very much, regards.

Hello @amacias,

Thank you for reporting your case.

We’re very sorry, this is an error in our documentation. Indeed, there is no dispose method in the API right now.
Please use the following code:

from aspose.email.storage.pst import PersonalStorage, FileFormatVersion
from aspose.email.mapi import MapiMessage

with PersonalStorage.create("AddMessagesToPst_out.pst", FileFormatVersion.UNICODE) as pst:
    # Add new folder "Inbox"
    inboxFolder = pst.root_folder.add_sub_folder("Inbox");
    # Add message to Inbox Folder
    inboxFolder.add_message(MapiMessage.from_file("MapiMsgWithPoll.msg"))

Thank you for the finding.

It works great in all cases where dispose() is used.

Thank you!

@amacias,

Thank you for your interest to our product.

Feel free to write to us if you have any additional query related to Aspose.Email. We’ll be glad to assist you further.