elwaha
asked on
Exchange 2007 Delete items in inbox 'x' days old
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.
Running Exchange 2007, outlook client 2007 and Archives (PST's) are turned off to the users.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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?
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?
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'.
Set it to clean out items older than 1 Month (or 30 days, or whatever) - and 'permanently delete old items'.
ASKER
No AutoArchive tab, The ability to create PST's has been disabled for all users.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've found this...
Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objNamespace = objOutlook.GetNamespace("M API")
Set objFolder = objNamespace.GetDefaultFol der(olFold erInbox)
Set colItems = objFolder.Items
Set colFilteredItems = colItems.Restrict("[UnRead ] = false")
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv edTime, 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?
Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Appl
Set objNamespace = objOutlook.GetNamespace("M
Set objFolder = objNamespace.GetDefaultFol
Set colItems = objFolder.Items
Set colFilteredItems = colItems.Restrict("[UnRead
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv
colFilteredItems(i).Delete
End If
Next
How can I set it to do the entire mailbox? Or other folders under my inbox?
Check this out; it should hit all the sub-folders of the Inbox as well:
Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objNamespace = objOutlook.GetNamespace("M API")
Set objInbox = objNamespace.GetDefaultFol der(olFold erInbox)
Set colItems = objInbox.Items
Set colFilteredItems = colItems.Restrict("[UnRead ] = False")
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv edTime, Now) > 1 Then
colFilteredItems(i).Delete
End If
Next
GetSubfolders(objInbox)
Sub GetSubfolders(objParentFol der)
Set colFolders = objParentFolder.Folders
For Each objFolder in colFolders
Set objSubfolder = objParentFolder.Folders(ob jFolder.Na me)
Set colItems = objfolder.items
Set ColFilteredItems = colItems.Restrict("[UnRead ] = False")
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv edTime, Now) > 1 Then
colFilteredItems(i).Delete
End If
Next
GetSubfolders objsubfolder
Next
end sub
Const olFolderInbox = 6
Set objOutlook = CreateObject("Outlook.Appl
Set objNamespace = objOutlook.GetNamespace("M
Set objInbox = objNamespace.GetDefaultFol
Set colItems = objInbox.Items
Set colFilteredItems = colItems.Restrict("[UnRead
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv
colFilteredItems(i).Delete
End If
Next
GetSubfolders(objInbox)
Sub GetSubfolders(objParentFol
Set colFolders = objParentFolder.Folders
For Each objFolder in colFolders
Set objSubfolder = objParentFolder.Folders(ob
Set colItems = objfolder.items
Set ColFilteredItems = colItems.Restrict("[UnRead
For i = colFilteredItems.Count to 1 Step - 1
If DateDiff("m", colFilteredItems(i).Receiv
colFilteredItems(i).Delete
End If
Next
GetSubfolders objsubfolder
Next
end sub
ASKER
To answer your first Q - Only on the users inbox, at the client.