Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open Outlook with specific .PST and folder 1

Status
Not open for further replies.

freddiekg

Programmer
Oct 13, 2009
25
0
0
MY
Dear all,

I like to create a button in a form that will open a Outlook application with a specific outlook .PST file (e.g. c:\test\testoutlook.pst) and also default to a specific folder (e.g. John Doe) that is under the "Personal Folders". Is that possible?

Thanks for your help in advance.
Freddie


 
I am almost certain that I have answered this question for you already elsewhere.

The biggest challenge in what you want to do is caused by Outlook, not VFP.

Outlook can only use the PST file(s) that it is configured to use. That configuration establishes a path and filename for the PST file.

And once Outlook is open, it 'captivates' that PST file so that it will not allow the file itself to change.

VFP can easily use the COPY FILE command to Move/Copy a file from one location to another and change its filename along the way. But if the file is 'captivated' by an Outlook session then a Sharing Violation will occur and the change in file will not occur.

One way to do this will work, but it is somewhat 'messy'.
VFP can close Outlook.

Then once Outlook is closed it can change the previously defined PST file itself from its original file to another file with something like this...
Code:
[B]cSource[/B] = C:\Documents and Settings\MySelf\Local Settings\Application Data\Microsoft\Outlook\File2.PST
[B]cDestination[/B] = C:\Documents and Settings\MySelf\Local Settings\Application Data\Microsoft\Outlook\Outlook.PST
[B]COPY FILE (cSource) TO (cDestination)[/B]

Now when Outlook is opened again (either by VFP or manually) the PST file will have the contents you desire.

There may be a way to change Outlook's pre-configured PST file path and filename within the Windows Registry, but I haven't tried that. HOWEVER, even if it could be done this way, Outlook would still need to be closed to make the change so that upon opening again it would use the new PST path/filename.

Good Luck,
JRB-Bldr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top