?
Solved

Exchange 2007 Delete items in inbox 'x' days old

Posted on 2007-10-11
9
Medium Priority
?
4,327 Views
Last Modified: 2010-07-28
I need to be able to delete Items in my inbox that are 'x' days old.  

Running Exchange 2007, outlook client 2007 and Archives (PST's) are turned off to the users.  
0
Comment
Question by:elwaha
  • 5
  • 4
9 Comments
 
LVL 19

Accepted Solution

by:
aissim earned 1000 total points
ID: 20061699
For just your mailbox - or all mailboxes in your organization?

Sounds like you might want to use the Messaging Records Management feature (equivalent to Mailbox Manager in 2000 & 2003).

Here's part 1 of a good 2 part article that discusses the feature and how to configure it:
http://www.msexchange.org/articles_tutorials/exchange-server-2007/compliance-policies-archiving/exchange-2007-messaging-records-management-part1.html
0
 

Author Comment

by:elwaha
ID: 20062034
Article good, reading now..

To answer your first Q - Only on the users inbox, at the client.  
0
 
LVL 19

Expert Comment

by:aissim
ID: 20062072
Good deal - just so you know, you CAN apply your policy to just the Inbox....it doesn't have to apply to all the managed folders.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

Author Comment

by:elwaha
ID: 20062103
Aissim,
Can you at the client setup something like that for the single user out there?
Or do you know of any scripts that a user can have that would accomplish deletion older than 30 days?
0
 
LVL 19

Expert Comment

by:aissim
ID: 20062169
Easiest way would be to right-click on the Inbox -> Properties. Switch to the AutoArchive tab and tick the 3rd radio button that reads "Archive this folder using these settings"

Set it to clean out items older than 1 Month (or 30 days, or whatever) - and 'permanently delete old items'.

0
 

Author Comment

by:elwaha
ID: 20062931
No AutoArchive tab,  The ability to create PST's has been disabled for all users.
0
 
LVL 19

Assisted Solution

by:aissim
aissim earned 1000 total points
ID: 20066493
Sorry - forgot that part :)

There are definitely scripting possibilities; I'm sure this script could be tweaked to be one month versus six...and not filtered down to just unread items, but simply all items in the Inbox:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun07/hey0629.mspx

Personally I would lean towards the MRM - part 2 of that article series...Step 4...discusses applying the policy to only one (or multiple) users.
0
 

Author Comment

by:elwaha
ID: 20069693
I've found this...

Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)

Set colItems = objFolder.Items
Set colFilteredItems = colItems.Restrict("[UnRead] = false")

For i = colFilteredItems.Count to 1 Step - 1
    If DateDiff("m", colFilteredItems(i).ReceivedTime, Now) > 1 Then
        colFilteredItems(i).Delete
    End If
Next

How can I set it to do the entire mailbox?  Or other folders under my inbox?
0
 
LVL 19

Expert Comment

by:aissim
ID: 20069819
Check this out; it should hit all the sub-folders of the Inbox as well:

Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNamespace.GetDefaultFolder(olFolderInbox)

Set colItems = objInbox.Items
Set colFilteredItems = colItems.Restrict("[UnRead] = False")

For i = colFilteredItems.Count to 1 Step - 1
    If DateDiff("m", colFilteredItems(i).ReceivedTime, Now) > 1 Then
        colFilteredItems(i).Delete
    End If
Next

GetSubfolders(objInbox)

Sub GetSubfolders(objParentFolder)
    Set colFolders = objParentFolder.Folders
    For Each objFolder in colFolders
      Set objSubfolder = objParentFolder.Folders(objFolder.Name)
      Set colItems = objfolder.items
      Set ColFilteredItems = colItems.Restrict("[UnRead] = False")
      
      For i = colFilteredItems.Count to 1 Step - 1
            If DateDiff("m", colFilteredItems(i).ReceivedTime, Now) > 1 Then
                    colFilteredItems(i).Delete
            End If
      Next

      GetSubfolders objsubfolder
    Next
end sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question