sample code for empty deleted items folder

T

Tom

sue mosher had this piece of code, question is, how would I use this to run
automatically for example at 05:00am ?

Function EmptyDeletedItems()
On Error GoTo ErrorHandler
Dim AppOutlook As Outlook.Application
Dim mNameSpace As NameSpace
Dim objExpl As Outlook.Explorer
Dim objCBB As CommandBarButton
Dim strEntryID As String
Dim strStoreID As String

Set AppOutlook = CreateObject("Outlook.Application")
Set mNameSpace = AppOutlook.GetNamespace("MAPI")
'Set the explorer to the active explorer
Set objExpl = AppOutlook.ActiveExplorer
'Capture the original current folder Entry and Store ID's
strEntryID = objExpl.CurrentFolder.EntryID
strStoreID = objExpl.CurrentFolder.StoreID
'Change the current folder to the target folder
Set objExpl.CurrentFolder =
mNameSpace.GetDefaultFolder(olFolderDeletedItems)
'Select the target folder
objExpl.SelectFolder mNameSpace.GetDefaultFolder(olFolderDeletedItems)
'Get the Empty Deleted Items command = UID 1671
Set objCBB = objExpl.CommandBars.FindControl(, 1671)
'Execute the command
objCBB.Execute
'Return to the original folder
Set objExpl.CurrentFolder = mNameSpace.GetFolderFromID(strEntryID,
strStoreID)

ExitHere:
On Error Resume Next
Set objCBB = Nothing
Set objExpl = Nothing
Set mNameSpace = Nothing
Set AppOutlook = Nothing
Exit Function
ErrorHandler:
Resume ExitHere
End Function
 
M

Michael Bauer [MVP - Outlook]

Copy the code into the module "ThisOutlookSession", and click Save. That's
it. Of course, you need to customize the strings, i.e. subject for the
reminder, etc.

Nothing needs to be enabled. The code will be called when a reminder pops
up, then it decides by the task's subject whether to continue or not.

--
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 Thu, 4 Sep 2008 16:52:22 +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