sample code to delete items in folder > 24 hours old

T

Tom

I have the following code sample in ThisOutLookSession and when I set a
breakpoint and step through the code, it does show the correct number of
items in Deleted Items folder - but does not delete them, no errors either

Sub CustomMailMessageRule (Item as Mailitem)

' at the very end of it, this is called
Call DeleteAllMailNotReceivedToday

End Sub

Sub DeleteAllMailNotReceivedToday()

Dim DL as outlook.items
Dim Om as Mailitem
Dim i as integer

set DL =
application.getnamespace("MAPI").getdefaultfolder(olfolderdeleteditems).items
for i = DL.Count to 1 step -1
set Om = DL.Item(i)
if datediff("h",Om.receivedtime, now()) > 24 then Om.Delete
next
set DL = nothing
set Om = nothing

End Sub
 
M

Michael Bauer [MVP - Outlook]

Is om.delete being called? You can easily check that, if you change the code
alittle bit:

if datediff("h",Om.receivedtime, now()) > 24 then
Om.Delete
endif

Now, you can put the breakpoint at the om.delete line.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 3 Sep 2008 18:55:24 +0300 schrieb Tom:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top