我想删除我的收件箱是90天前的所有邮件。 我不能使用自动存档,因为它已经在我的办公室被禁用。 我有一些代码,似乎并没有被删除每个邮件是超过90天。 我认为这个问题可能与我的循环。 我使用Outlook 2010与Exchange 2010。
Private Sub RemoveEmail90()
Dim olSession As Outlook.Application, olNamespace As NameSpace
Dim olInbox As Outlook.MAPIFolder
Dim i As Integer
Set olSession = New Outlook.Application
Set olNamespace = olSession.GetNamespace("MAPI")
Set olInbox = olNamespace.GetDefaultFolder(olFolderInbox)
Set Delete_Items = olInbox.Items
For i = Delete_Items.Count To 1 Step -1
If TypeName(Delete_Items.Item(i)) = "MailItem" Then
If DateDiff("d",now, Delete_Items.Item(i).ReceivedTime) > 90 Then Delete_Items.Item(i).Delete
End If
Next
Set olSession = Nothing
Set olNamespace = Nothing
Set olInbox = Nothing
End Sub