A user deleted an IMAP account from his profile, but the IMAP .OST file was not removed. When he tried to remove it from the Data Files tab in File > Account Settings, the error message said it was linked to an email account and he needed to delete the email account to remove the data file. When he tried to look at the contents of the file in Outlook's folder list, the folders wouldn’t expand.
One option is to create a new profile. While this is easy for anyone with just a couple of accounts in their profile, this user had a lot of accounts and .PST files so a new profile was the option of last resort.
Fortunately, you can fix it without making a new profile, however, you need to edit the registry.
Note: editing the profile in the registry is {"at your own risk". Fortunately, provided you touch only keys within the profile key, the worst you'll do is screw up the profile and need to make a new one, if you didn't export the profile keys first. You won't render Windows inoperable.
To delete a ghost file, you will need to search the registry for the data file name. But the data file name is in hex format, so you need to search for the value it is stored in, then open the value and look for the file name in the data.
- Open the registry Editor and go to HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles\Outlook
- Export the Profile keys just in case you make a mistake and want to try again.
- Open the Find dialog and enter 01020ffb.
- Open each 01020ffb value that is found, scroll to the end of the dialog, and look for the data file name.
- If the name is the same as the ghost data file, right-click on the key on the left to delete the entire key on the left side.
- Press F3 to continue searching as there are two keys for the data file and you need to delete both keys to remove the ghost file.
Around the same time, his search quit working correctly. He could find things using the All Mailboxes search scope but the Current folder scope often failed. After removing the ghost data file from his profile, search started working too.
More Information
To delete a ghost .pst file, search for 001e3001 for the .pst name or 01020fff for the .pst file path.