Issue in releasing memory from Outlook pst file

I am working on a win application that accesses Outlook personal folders. Internally, it mounts the personal folder in the Outlook instance and processes the mail, and then disables pst. After unmounting pst, I delete this file.

Now the problem is that even after un-installing pst and freeing up memory, when I try to remove pst, I get an exception that some process uses this file, so it cannot be deleted. And this process is a perspective. I use the following code to install and free memory:

_application.Session.RemoveStore(_personalFolder); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(_personalFolder) >= 0) ; _personalFolder = null; 

I checked it many times, and it seems that it takes some time to free memory, and there is no specific time for this. Can someone help me delete the file?

+1
object outlook com
Jan 28 '09 at 8:29
source share
1 answer

See KB234228 ("OL97: Outlook.pst Lock Lock Release Interval Now Configurable") . It's about Outlook 97, but I would suggest that it still works.

I think that FileSystemWatcher will not help you, since there is no event with exclusive blocking.

So, perhaps you can create a workflow that is constantly trying to delete all the .pst files that you put in the queue. Thus, the user interface of the application can at least continue to work.

Tools like ProcMon have the ability to view application file descriptors. Perhaps you can make an API call that allows you to do this for the Oulook process (this is good stuff for another SO question, I think). Thus, you do not need to check the file system and act faster when the lock disappears.

If you dare, you can even immediately try to close the file handler, eliminating the need for polling / waiting at all.

+1
Jan 30 '09 at 9:38
source share



All Articles