The Outlook Secure Temp Folder
Every time you open or preview an attachment in Outlook, a copy of the file is cached to your Outlook Secure Temp Folder. The Outlook Secure Temp Folder is a directory with a randomly generated name, whose path you can obtain by viewing the OutlookSecureTempFolder string value under HKCU\Software\Microsoft\Office\[Version]\Outlook\Security in your registry. The files written to this folder are supposed to be automatically deleted once the messages associated with them are closed, but this does not always happen as expected. Residual file copies can be left behind in the secure temp folder for a number of different reasons, such as an unexpected closure of Outlook while attachments remain open. However, I've found that files are often orphaned in this directory just from viewing them with the built-in attachment previewer. Over time, these files can begin to cause attachment viewing problems.
Outlook "Can't Create File" Error
Outlook users who frequently receive e-mail messages containing attachments with identical names may find that they eventually begin receiving error messages when attempting to open these attachments. Let's say that you receive a daily sales report entitled SalesReport.pdf. Every time you open this file, Outlook attempts to cache a copy of it to your Secure Temp Folder, as described above. If a previously orphaned file exists with the same name, Outlook attempts to create the file by adding a number to the end of the file name, and sequentially incrementing it until there is no naming conflict with other files in the Temp directory. Upon viewing your temp directory, you may see multiple copies of the report named as follows: SalesReport.pdf, SalesReport (2).pdf, SalesReport (3).pdf, etc. Issues seem to crop up when the number of similarly named files in the directory approaches 100. Once this threshold is reached, Outlook begins to deny users the ability to open attached files with the same name, because it will no longer increment the file name, and therefore cannot create a cached copy of the data to open locally. The result is an error message similar to the following: "Can't create file: SalesReport.pdf. Right-click the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions for the folder". This cryptic message is both frustrating and confusing to most end-users, and tends to cause quite a bit of disdain when time-sensitive documents are involved.
Purging the Outlook Secure Temp Folder
The solution to the "Can't create file" error is to purge the contents of your Outlook Secure Temp Folder. Once the orphaned files in this directory are removed, Outlook can once again create cached copies of e-mail attachments on your local machine for opening. The temp folder can be purged manually by navigating to its path as indicated in the registry (HKCU\Software\Microsoft\Office\[Version]\Outlook\Security\OutlookSecureTempFolder) and deleting all existing files, or you can use the OutlookTempFolderPurge.vbs script that I've posted below to do this for you:
If you are running multiple versions of Office/Outlook, the script will clear the contents of all temp folder instances. By default, the script notifies you upon completion of any errors encountered, but this behavior can be altered by setting the "InformUser" variable to "False" (without the quotes) where indicated. You can simply run this script on-demand every time the problem occurs. If you wish to be more proactive, you can also place it in your startup folder, or include it in a logon script for your users, so that the data is purged with every subsequent logon.