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.
Updated code: Macro now changes the backup folders to the correct item type.
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 Dim oPA As Outlook.PropertyAccessor Dim PropName, Value As String PropName = "http://schemas.microsoft.com/mapi/proptag/0x3613001E" 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 Value = "IPF.Appointment" Case 2 folderType = olFolderContacts Value = "IPF.Contact" Case 3 folderType = olFolderTasks Value = "IPF.Task" Case 4 folderType = olFolderNotes Value = "IPF.StickyNote" End Select Set copyFrom = objNS.GetDefaultFolder(folderType) Set myBackup = copyFrom.CopyTo(copyToDataFile) Set oPA = myBackup.PropertyAccessor oPA.SetProperty PropName, Value Next i ' remove the pst from the folder list 'objNS.RemoveStore (objFolder) Set oPA = Nothing 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