I have created a button in outlook 2003 utililizing the following VBA code:
Public Sub EmptyJunkEmailFolder()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Dim olitem As Object
Dim fldJunk As Outlook.MAPIFolder
Dim gone As Date
gone = Date
Set fldJunk = NS.GetDefaultFolder(olFolderJunk)
For Each olitem In fldJunk.Items
If olitem.ReceivedTime < gone Then
olitem.Delete
End If
Next
Set fldJunk = Nothing
Set olitem = Nothing
Set NS = Nothing
End Sub
The problem is it seems to only do a few at a time. I have to click it numerous times before it stops deleting as the only remaining emails are toddays.
I am slightly confused...
Please help.
Public Sub EmptyJunkEmailFolder()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Dim olitem As Object
Dim fldJunk As Outlook.MAPIFolder
Dim gone As Date
gone = Date
Set fldJunk = NS.GetDefaultFolder(olFolderJunk)
For Each olitem In fldJunk.Items
If olitem.ReceivedTime < gone Then
olitem.Delete
End If
Next
Set fldJunk = Nothing
Set olitem = Nothing
Set NS = Nothing
End Sub
The problem is it seems to only do a few at a time. I have to click it numerous times before it stops deleting as the only remaining emails are toddays.
I am slightly confused...
Please help.