Auto Outlook Archive Email
What does it mean to archive an email? When we get too many emails in Inbox @ work, it wastes our time in browsing through all mail items.
We spend too much effort in cautiously picking important items & keeping aside unwanted items. Not only our productive time and effort get wasted, but also Outlook application’s performance goes down. So, it is always good to backup mails periodically to a different PST by setting up Auto Outlook archive Email.
This article explains 2 methods of archiving Outlook emails. First through the built in option by creating a Outlook Archive Folder and the second through a VBA Macro code to move Emails in your inbox to PST, when they become older than a predefined time interval.
How To Archive Email in Outlook?
To do this process, first create a PST folder specifically to store these backup emails. Then follow these steps.
- Open you Outlook application.
- Click on Menu -> File -> Archiving (in Office Version 2007).
- Select Email Folder to be archived.
- Choose date for “Archive Items Older than’ field.
- Choose archival PST file, where the emails have to backup.
This completes the setup for Auto Outlook Archive Email. The eMail items older than the date specified in Steps 4 – will be moved to Outlook archive Folder.
These steps might be slightly different in the higher versions of Office application, but the steps are the same.
Also Read: VBA to Delete File in a Folder
Export eMails To PST – Outlook Backup all Emails
Now, let’s focus on how to move an email items to a PST folder & Archive emails in Outlook through VBA. Open the Outlook application and press “Alt+F11”. This will open the VB Editor.
- Copy paste the below code.
- Change source & destination Mailbox and Folder name.
- In this code, the mails older than 100 days will be moved to PST. Modify it as per your need.
Note: Before testing this code, keep a copy of your PST in separate folder to prevent accidental data loss.Auto Outlook Archive EmailsVisual Basic1234567891011121314151617181920212223242526272829303132333435Sub Archive_Outlook_eMails_To_Backup_PST_Folder()' Declare Objects for Outlook Archive EmailDim SourceFolder As Outlook.MAPIFolder, DestFolder As Outlook.MAPIFolderDim MailItem As Outlook.MailItemDim SourceMailBoxName As String, DestMailBoxName As StringDim Source_Pst_Folder_Name As String, Dest_Pst_Folder_Name As StringDim MailsCount As Double, NumberOfDays As Double'Set Number of days for aging checkNumberOfDays = 1'Source Mailbox or PST nameSourceMailBoxName = "YourEmailAccount@gmail.com"Source_Pst_Folder_Name = "SourcePSTFolder"Set SourceFolder = Outlook.Session.Folders(SourceMailBoxName).Folders(Source_Pst_Folder_Name)'Backup to this Mailbox or PST nameDestMailBoxName = "Archive Folders"Dest_Pst_Folder_Name = "Inbox"Set DestFolder = Outlook.Session.Folders(DestMailBoxName).Folders(Dest_Pst_Folder_Name)MailsCount = SourceFolder.Items.CountWhile MailsCount > 0'Backup Mails Older than "Number of Days"Set MailItem = SourceFolder.Items.Item(MailsCount)If VBA.DateValue(VBA.Now) - VBA.DateValue(MailItem.ReceivedTime) >= NumberOfDays ThenSourceFolder.Items.Item(MailsCount).Move DestFolderEnd IfMailsCount = MailsCount - 1WendMsgBox "Mailes in " & Source_Pst_Folder_Name & " are Processed"End Sub
To execute this code, press “F5” or if you want to debug the code line by line press F8. Also make sure that the Mailbox & Folder names are mentioned correctly before executing the code.
Also Read: Send Automated Emails through VBA Macro
By using this code, you can archive Outlook mail items to 1 or more back up PST file. This way, when any data is accidentally lost, then we have additional place to look for. These days cloud storage systems are gaining popularity, where people keep an offsite backup of data and emails, so that data can be recovered even when whole system goes down.
Outlook Archive Email – Move Email To PST – VBA Macro
- Block Apps in FaceBook print screen Excel Countif Record Macro Timer in Excel Task Manager VCF HTML Table Import Data Thumbnails Text to Speech TTS Candy Crush C++ Programing Machine learning AI bulk email Excel VBA vba color index vba color codes Android social media Twitter Google+ Google Adsense Tips bitcoin Calendar in Excel outlook vba mass email Data Mining Excel Macro Facebook WhatsApp Wordpress python