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
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