Some users would like to configure their Outlook to automatically archive a flagged email as soon as they mark it complete. This article will guide you to achieve it with Outlook VBA.
In Outlook, “flag” feature helps us a lot in following up the important emails. As you think that a flagged email is not needful any longer, you can mark it complete. At that point, you may want to archive it for cleaning up the useless item. Now, in the followings, we will introduce a solution to let Outlook auto perform this.
Auto Archive a Flagged Email after Marking It Complete
- At the very outset, start your Outlook application.
- Then, access Outlook VBA editor with reference to the article – “How to Run VBA Code in Your Outlook”.
- Next, copy and paste the following VBA code into the “ThisOutlookSession” project.
Public WithEvents objItems As Outlook.Items Private Sub Application_Startup() 'Works on inbox items Set objItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub objItems_ItemChange(ByVal Item As Object) Dim objMail As Outlook.MailItem Dim objArchivePSTFile, objArchiveFolder As Outlook.Folder If Item.Class = olMail Then Set objMail = Item 'When marking an email complete If objMail.FlagStatus = olFlagComplete Then If MsgBox("Wanna Archive It Now?", vbYesNo + vbQuestion, "Archive Completed Mails") = vbYes Then 'Add the specific Archive PST file Application.Session.AddStore "C:\Users\Test\Documents\Outlook Files\Archive.pst" Set objArchivePSTFile = Application.Session.Folders("Archives") 'Get the specific folder called as "Follow Up" On Error Resume Next Set objArchiveFolder = objArchivePSTFile.Folders("Follow Up") If objArchiveFolder Is Nothing Then Set objArchiveFolder = objArchivePSTFile.Folders.Add("Follow Up") End If 'Archive the email to the specific folder objMail.Move objArchiveFolder 'To close the archive pst file, use the following line 'Application.Session.RemoveStore objArchivePSTFile End If End If End If End Sub
- After that, you can restart your Outlook application to activate the macro.
- From now on, every time when you mark a flagged email in Inbox complete, it will be auto archived to the “Follow Up” mail folder in the specific Archive PST file.
Unable to Escape from Corruption
As we all know, Outlook satisfies many users’ requirements. Thereby, it has been preferred by a majority of users. However, Outlook is incapable of getting rid of errors and damage. Hence, users should always keep an eye on its health. You can make Outlook data backups at regular intervals. Also, it’s suggested to get hold of a potent external Outlook fix tool, such as DataNumen Outlook Repair. It can help you to deal with Outlook troubles with effortless ease.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf fix and outlook repair software products. For more information visit www.datanumen.com