How can I open an Outlook data file programmatically? - outlook

In my current environment, I have to run Outlook as administrator on my workstation and that doesn't play well with some of my other software that is using the Outlook 2010 Developer Reference to move messages around in the Outlook mailbox.
The only thing I've been able to do to keep from getting the error code 0x8004010F is to "Close" the most current Outlook Data File I use as permanent storage and then reopen it. However, I need to do that now programmatically. I can't find anything in the Outlook 2010 Developer Reference about opening/closing the data files but surely Outlook can do it.
How can I do this?
Clarification: When I say that I need to 'close then open' the data file, it is within the current session of the Outlook mail client. The act of closing/opening the data file allows Outlook to receive/process the commands to move messages within the Exchange storage space.

The error is MAPI_E_NOT_FOUND. What exactly raises that error?
You can use Namespace.AddStore/AddStoreEx to add a PST store and Namespace.RemoveStore to close it. Keep in mind however that the PST provider will still keep the PST file locked for 30 minutes or until Outlook closes.

Related

Powershell Script to Create Outlook 2019 Personal Folder

Currently users have their own inbox folder and due to corporate policy emails will automatically be deleted after a set period of time.
Some emails however users would like to be able to keep for reference.
In order to accomplish allowing users to keep their importasnt emails; a personal folder file .pst needs to be created. The deletion policy will on affect the exchange profile folder that they currently use. This special personal folder should not be touched by the corporate system.
I need to be able to run a powershell script to automatically create this folder for the user (logged in user on the computer) and assign it in outlook 2019 for use, the user will then copy their specific emails into that personal folder. If I can't do it for the current logged in user - then by a collection of usernames and put in their one drive folder ??
Anyone with knowledge of how to or code to do this, I would appreciate your help - while I can code - I'am not a Powershell Guru so specifics and functions that experts might know exactly - I do not know, so please in your answer provide good guidance.
I am using windows 10 .1909 and the powershell version that ships with it.
The Outlook object model provides the AddStoreEx method which adds a Personal Folders file (.pst) in the specified format to the current profile.
Sub CreateUnicodePST()
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = Application.GetNamespace("MAPI")
myNameSpace.AddStoreEx "c:\" & myNameSpace.CurrentUser & "\.pst",olStoreUnicode
End Sub
After creating additional storage in the Outlook profile users can move items for keeping them locally. Or you may consider creating a VBA script or COM add-in for doing that programmatically. See Walkthrough: Create your first VSTO Add-in for Outlook for getting started quickly.

Accidentally Delete PST Files Of Outlook

I have accidentally deleted OUTLOOK 365 users*.pst files.
Then I have re-installed Office 365.
Now Outlook raises message at start up like "The file c:\users\onedrive\documents"outlook files..*.pst" cannot be found, and closes.
I have read recovery advices, but coluld not found scanpst.exe even.
Any help will be appreciated.
Open Outlook
Without Selecting a PST file, enter OPEN on coming Dialog Box
Enter Password you have already
Outlook Opens, Type 'Add Account' on Search Box, related tool comes
Add your Mail Accounts.

How to delete pst file after deleting store using c#

I m removing the store and would like to delete the .pst file associated with it. I am developing a VSTO addin, where in once user logout then I would like to delete .pst file created for it. Again when user login, then will create new store and new .pst file associated with it.
PST provider keeps the PST file open for 30 minutes (or until the process terminates) for the performance and sharing purposes after it is removed from a profile.
You might want to play with the registry key mentioned in https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/222328 to make sure the file is closed sooner.
If this is a temporary PST file that the end user does not necessarily need to see, you can create an auxiliary exe that processes the PST. After the process exits, the PST file can be deleted. Note that you would need to use Extended MAPI (C++ or Delphi only) or Redemption (I am its author - any language, use RDOSession.LogonPstStore) as the Outlook Object Model calls would still be marshalled back to the outlook.exe address space where your addin is running.

Outlook 2016 Rules Turn Off After Restart

I have created rules within outlook 2016 and run well. However, when i close outlook and restart my pc. This rules seem to stopped from work. And all the emails that has been moved to another folder, comeback to inbox folder.
However, when i close outlook and restart my pc. This rules seem to stopped from work.
You need to make sure that VBA macros are allowed to run in Trust Center.
And all the emails that has been moved to another folder, comeback to inbox folder.
It's impossible without any code or user interactions.

Locked excel sheet that isn't open

I am trying to open a locked excel sheet. The warning says it is locked because it is being used by "AN Other".
This person does not have the sheet open, does not have any excel applications open, does not have any excel based tasks running in the task list and has tried the good old "turning it off and on again".
Neither of us can save onto this filename, change it in windows explorer or delete the file.
We have "saved as" another name but really need the original name. I looked at a few forums and they suggest this is an excel/windows bug.
Am using excel 2010 and Windows 7.
You need to get in touch with your IT support.
In a company network, a file will be locked for other users when somebody edits it. It can happen sometimes that the file does not get released (unlocked) when the user closes it. Your IT Support people need to unlock the file, so you can edit it again.

Resources