Closing PST

Hi

I wrote a test program using Aspose.Email to create a PST file (or open an existing one) and import a message.
The newly created PST file remains in use until my test program is running. Is there a way to gracefully close the PST file, so that I’m able to load it in outlook.
This is a strict requirement since my test code is supposed to be inserted in a windows service, and I cannot wait for the service to stop :slight_smile:

thank you in advance
stefano

Hi Stefano,


Thank you for using Aspose.Email.

Well, this is actually a limitation associated with PST files that the existing process needs to be closed before it could be used by any other process. I am afraid but there is no other way to do so other than closing the existing process that holds the PST.

Hi Kashif

thank you very much for your answer.
I have two more questions
1. is there any plan to fix this behavior?
2. does the fact that the PST file remain opened till the existing process is running mean that I should aspect memory leaks in my service?

thanks
stefano

Hi Stefano,


This behavior is not an issue of Aspose.Email. Create a PST using Microsoft.Office.Interop.Outlook and leave this process running. Now try to access the same PST file from other process using Aspose.Email and you will observe the same exception as given below:
“The process cannot access the file ‘D:\Aspose\Test.pst’ because it is being used by another process.”. This is limitation of OS and cannot be fixed by Aspose.Email.

There may be an argument that PST created by Microsoft.Office.Interop.Outlook can be opened by Outlook simultaneously. Its reason is obvious as Microsoft.Office.Interop.Outlook shares the same process, therefore it is authorized to access the same PST. As Aspose.Email works independent of Outlook installed on the system, so it does not share the same process.
.
Please feel free to write us back if you have any other query in this regard.

Hi Kashif

I understand :frowning:
I’m going to isolate the PST manipulation code in a different executable. Then I’ll use CreateProcess() to launch it from my service.
Can you suggest a different solution?
thanks
stefano

Hi Stefano,


I am afraid I couldn’t find any other such method where this can be achieved simultaneously. However, I’ll try to experiment with it a little more and will write back here if I find any such way to achieve this.