Outlook 2013 allows users to set the IMAP data files as the default data file. As a result, appointments, contacts, tasks, and notes are stored in the IMAP data file. While many users like this because it means there is only one data file in the profile, it can result in data loss if you delete the account or the IMAP *.ost file and didn't export the folders labeled 'this computer only' first.
You should export these folders daily or weekly to create a backup copy, depending on how often they change. Note: backing up the IMAP .ost files is pointless - only the account and profile that created it can open it.
To make it easier to make a backup, you can use a macro to copy the Calendar, Contacts, Tasks, and Notes folders to a new .pst file.
This macro creates a new pst file in the My Documents\ Outlook Files folder, using a file name containing the date and time the backup was created, in the format of yyyymmddhhmmss-Backup.pst. The pst's display name is changed to Backup-yyyymmddhhmmss.
If you need to restore the contents of the folders, you can Import, using this pst file as the source or Select All and Copy then use the Move to Folder command or Paste the items into the IMAP folders.
Macro to create backups
Note: this macro assumes only the default IMAP data file is in the profile.
Sub CreateBackupFiles() Dim OlApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim copyToDataFile As Outlook.Folder Dim copyFrom As Outlook.Folder Dim myBackup As Outlook.Folder Dim objFolder As Outlook.Folder Dim folderType Dim enviro As String, strDate As String Dim strFileName As String, pstName As String Set objNS = Application.GetNamespace("MAPI") enviro = CStr(Environ("USERPROFILE")) strDate = Format(Date, "yyyymmdd") & Format(Time, "hhmmss") strFileName = enviro & "\Documents\Outlook Files\" & strDate & "-BackUp" & ".pst" pstName = "Backup " & strDate Debug.Print strFileName ' Create the backup pst file objNS.AddStore strFileName Set objFolder = objNS.Folders.GetLast objFolder.Name = pstName Set copyToDataFile = Application.Session.Folders.Item(pstName) For i = 1 To 4 Select Case i Case 1 folderType = olFolderCalendar Case 2 folderType = olFolderContacts Case 3 folderType = olFolderTasks Case 4 folderType = olFolderNotes End Select Set copyFrom = objNS.GetDefaultFolder(folderType) Set myBackup = copyFrom.CopyTo(copyToDataFile) Next i ' remove the pst from the folder list objNS.RemoveStore (objFolder) Set objNS = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor