The workaround that I can think of is to sort the messages accroding to date (from latest to oldest), select the latest emails and move it to a newly created folder and then delete the rest of the emails in your inbox. Delete files older than x-days - Cleanup Script Script to delete files older than x-days. The script is built to be used as a scheduled task, it automatically generates a log file based on the copy location and the current date/time.
Posting this answer here since on another post answered it was tagged as a duplicate of this post. The below answer has more detail than the equivalent answer here so someone may find this helpful with the need. You can combine a Rules Wizard rule with the AutoArchive feature of Microsoft Outlook to automatically delete messages as they age.
There are two ways you can do this:. Create a rule that moves messages meeting certain criteria to a folder.
Configure the folder's Archive setting to delete messages. Setting an expire date on messages as they arrive. In either case, AutoArchive will delete the messages for you once they age. If you need help configuring autoarchive settings, watch the tutorial: Move messages to a new folder.
Create a rule that moves messages to a folder. Switch to this folder, then right click on the folder and choose Properties. On the AutoArchive tab, choose how often to clean out items and whether they should be archived or deleted. Set an expiration date on the messages Follow these steps to create a run a script rule to add an expire date and then configure AutoArchive to delete the messages. When a message is expired it's displayed in the message list in a gray strikethrough font. Macro security should be set to Low during testing. Once you verify the macro works, you can use, at which point you will change the security setting to allow signed macros only.
In Outlook 2010 and 2013, click File, Options, Trust Center. Click the Trust Center Settings button then Macro Security.
Select the bottom option for Low security. In Outlook 2007, look on the Tools menu for Trust Center, then Macro Security. In older versions of Outlook, go to Tools, Macros, Macro Security. Press Alt+F11 to open the VBA Editor.
Right click on Project1 and choose Insert Module. Add the macro below to the new module.
Create a rule, selecting Run a Script as the action. If you set all of the conditions in the rule, you can delete the If.Then and End If lines. Create a filter for your view that hides expired messages between AutoArchive runs.
Configure AutoArchive to delete expired messages The macro will set the message to expire in 1 day. You can use.5 to expire the message after 12 hours.
If you use conditions in the rule to filter the messages, you can remove the If.Then and End If lines from the code. Sub SetExpire(Item As Outlook.MailItem) If Left(LCase(Item.Subject), 7) = 'weather' Then Item.ExpiryTime = Now + 1 Item.Save End If End Sub. This is for Microsoft Office Outlook 2007 running on Windows 7 This is a 2 step process. First you have to turn on the Global Auto Archive option. (assuming you are not using AutoArchive presently) In Outlook menu Tools:Options.
Select 'Other' tab. Select 'AutoArchive.' Here we turn on the global Auto Archive function (so we can setup individual folder (deleted items) options. If you do not use AutoArchive, and you only want to delete your old Deleted Items, the only check box that should be selected is: Run AutoArchive every XX days. Select this check box and put in a number less than or equal to the time you want your trash can to remove old items. For example, if you want your Deleted Items (trash can) to get rid of items that are older than 2 months, you could select '30' days in this Global AutoArchive. What is really happening is that this Global AutoArchive is going to trigger every 30 days, which will trigger the AutoArchive on the Deleted Items that we are going to setup next.
The section under 'During AutoArchive:' you don't want any of those check boxes selected. These are for global settings, and will have an effect on all your email folders. Click the OK button to accept those changes (closes window), then click OK again on Options control panel. Now we will setup the trash can AutoArchive options.
If you right click the trash can (Deleted Items) in Outlook, select Properties. Select the AutoArchive tab. Select radio button: Archive this folder using these settings.
There you can select how long to keep the emails in the trash (you can select the number of months weeks or days. Then select the sub radio button: Permanently delete old items. (other options include move old items to default archive folder, or move old items to a local directory. I hope this was helpful REAndy.
If you need help configuring autoarchive settings, watch the tutorial:. Note: If you use Microsoft Exchange Server 2010 with online mailbox archives, you won't be able to use autoarchive in Outlook 2007 and 2010. Set an expiration date on the messages Follow these steps to create a run a script rule to add an expire date and then configure AutoArchive to delete the messages. When a message is expired it's displayed in the message list in a gray strikethrough font. Macro security should be set to Low during testing. Once you verify the macro works, you can use, at which point you will change the security setting to allow signed macros only. In Outlook 2010 and 2013, click File, Options, Trust Center.
Click the Trust Center Settings button then Macro Settings. Select the bottom option for Low security.
In Outlook 2007, look on the Tools menu for Trust Center, then Macro Security. In older versions of Outlook, go to Tools, Macros, Macro Security. Press Alt+F11 to open the VBA Editor. Right click on Project1 and choose Insert Module.
Add the macro below to the new module. Create a rule, selecting Run a Script as the action.
If you set all of the conditions in the rule, you can delete the If.Then and End If lines. Create a filter for your view that hides expired messages between AutoArchive runs. Configure AutoArchive to delete expired messages. The macro will set the message to expire in 1 day. You can use.5 to expire the message after 12 hours.
If you use conditions in the rule to filter the messages, you can remove the If.Then and End If lines from the code. Sub SetExpire(Item As Outlook.MailItem) If Left(LCase(Item.Subject), 7) = 'weather' Then Item.ExpiryTime = Now + 1 Item.Save End If End Sub If you use Outlook 2013 or Outlook 2016 and don't see the run a script option in rules, see Move messages to a new folder. Sorry, but not quite following the steps. I've completed the Trust Center step I've added the macro (module?) in that you provided (SetExpire) and just changed the subject to something I'm interested in But step 4, understand that this has changed and it needs to be another macro - tried to use your example and added another module but can't get it to run and so guessing my first macro (module?) isn't running either.
In step 5 - where does one create a filter? And since I (want) to run auto-archive daily and my macro flags them 1 day, not sure I need this step, but am curious.
Step 6 - this is for turning it on globally, correct? Just 'nervous' that there may be other emails that are set to expire that I didn't set - or my macro is wonky and I just flagged ever email to expire. Sorry for all the questions, if you have a example for this topic but at a lower level or with video, can you point me to it? Thanks a ton in advance, this would be a huge help for both my wife and I.
Hi Diane, i'm sorry but i couldnt see how to start a new question??? Thank you for all your help, i have used Slipstick many times but never asked a question. My question is about steps 4 and 5 above ( I have done 1 -3), where do i 'create a rule' and ' create a filter, i can't see anywhere in VBA editor and in Create Rule in Outlook (2013) there is no option to Run a Script.
Also, fyi, when i went into Trust Center (2013) there was no 'Macro Security' but there was Macro Settings which had options to change security levels. Thank you for you help. I also got an issue, using outlook 2013, created 2 rules, one to move messages from inbox to local inbox (pst) and copy messages from send items to local send items - because i can't configure a move rule for that folder. I have deactivated autoarchive general settings from file-options-advanced-autoarchive and only configured autoarchive on the send items folder with following options: clean out items older then 1 day and permanently delete old items.
Unfortunately any emails older then 1 day don't get deleted as they are supposed to. Can't seem to find where i did wrong.