Help finish a script for Outlook to delete contents of 'Conflicts' folder.

From this question - http://www.experts-exchange.com/Microsoft/Applications/Q_24872180.html?sfQueryTermInfo=1+10+30+conflict+issu+outlook+sync

There was a script posted that would clean out the "Sync Issues" folder (see below).  In the question, the asker was able to modify it to clean-out the 'Conflicts' subfolder.  Since that is the folder I see most frequently as problematic, and since I also have no experience with what looks to be VBscript, would anybody be so kind as to 'finish' the script to include the "Conflicts" folder, too, please?  With that, I think I'd be able to figure out how to include 'Local Failures' and 'Server Failures' ...

Thank you in advance.


Private Sub Application_Startup()
    ClearSyncFolder
End Sub 
Sub ClearSyncFolder()
    Dim olkFolder As Outlook.Folder, _
        lngPointer As Long
    Set olkFolder = Session.GetDefaultFolder(olFolderSyncIssues)
    For lngPointer = olkFolder.Items.count To 1 Step -1
        olkFolder.Items.Item(lngPointer).Delete
    Next
    Set olkFolder = Nothing
End Sub

Open in new window

LVL 3
djhathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheGorbyCommented:
I believe this will do the trick:
Private Sub Application_Startup() 
    ClearSyncFolder 
End Sub  
Sub ClearSyncFolder() 
    Dim olkFolder As Outlook.Folder, _ 
        lngPointer As Long 
    Set olkFolder = Session.GetDefaultFolder(olFolderSyncIssues) 
    For lngPointer = olkFolder.Items.count To 1 Step -1 
        olkFolder.Items.Item(lngPointer).Delete 
    Next
    Set olkFolder = Session.GetDefaultFolder(olFolderConflicts) 
    For lngPointer = olkFolder.Items.count To 1 Step -1 
        olkFolder.Items.Item(lngPointer).Delete 
    Next
    Set olkFolder = Nothing 
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David LeeCommented:
Hi, djhath.

Another approach is to clear all subfolders through recurrsive calls to the same procedure.  This version of the script gets the Sync Issues folder, clears it, then clears all the folders beneath it.
Private Sub Application_Startup()
    ClearFolder .GetDefaultFolder(olFolderSyncIssues)
End Sub 

Sub ClearFolder(olkFolder As Outlook.Folder)
    Dim lngPointer As Long, _
        olkSubFolder As Outlook.Folder
    For lngPointer = olkFolder.Items.count To 1 Step -1
        olkFolder.Items.Item(lngPointer).Delete
    Next
    For Each olkSubFolder in olkFolder.Folders
        ClearFolder olkSubFolder
    Next
    Set olkSubFolder = Nothing
End Sub

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.