Link to home
Start Free TrialLog in
Avatar of djhath
djhathFlag for United States of America

asked on

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

From this question - https://www.experts-exchange.com/questions/24872180/Empty-Sync-Issues-Conflicts-Folders-in-Outlook-2007.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

ASKER CERTIFIED SOLUTION
Avatar of TheGorby
TheGorby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Lee
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