# VBForums CodeBank > CodeBank - Visual Basic .NET >  Cleaning Outllook "Sync Issues" folder

## Thierry69

In Outlook you can find the "Sync Issues" folder that s filled QUITE A LOT (at least on my computers here).


This is due to some conflict whenusing IMAP and several computers/clients etc...

This folder contained several thousand of message (in fact, those logs are created on regular basis).
Of course, you can delete them manually.

I searched the web for an addin or code doing a clean, but nothing found.
So, I wrote a small code in VB.NET that I added to my Outlook Addin that cleans automatically at startup of Outlook.


Code Code:
Public Sub Outlook_Clean_SyncIssues(oOutlook As Outlook.Application)
         Dim oNameSpace As Outlook.NameSpace
        Dim oStore As Outlook.Store
         Dim oFolder As Outlook.Folder
        Dim aFolderConflicts() As Long = {20, 19, 22} ' olFolderSyncIssues, olFolderConflicts, olFolderServerFailures
        Dim nFolder As Long
         Dim nMessages As Long
        Dim nMessage As Long
         Try
            oNameSpace = oOutlook.GetNamespace("MAPI")
             For Each oStore In oNameSpace.Stores
                For Each nFolder In aFolderConflicts
                    oFolder = Nothing
                    Try
                        oFolder = oStore.GetDefaultFolder(nFolder)
                    Catch ex As Exception
                    End Try
                     If Not (oFolder Is Nothing) Then
                        nMessages = oFolder.Items.Count
                        Debug(oStore.DisplayName & " (" & nMessages & ")")
                        If nMessages <> 0 Then
                            For nMessage = nMessages To 1 Step -1
                                'oFolder.Items.Item(nMessage).Delete
                                Debug(oFolder.Items.Item(nMessage).Subject)
                            Next
                        End If
                    End If
                Next
            Next
        Catch ex As Exception
            Debug(ex.Message)
        End Try
     End Sub
     Private Sub Trace(sFormat As String, ParamArray args As Object())
         Diagnostics.Debug.Print(sFormat, args)
     End Sub
     Public Sub Debug(Optional sData As String = vbNullString)
         Dim StackTrace As New System.Diagnostics.StackTrace()
        Dim Frame As Diagnostics.StackFrame = StackTrace.GetFrame(1)
        Trace(FormatDateTime(Now, DateFormat.ShortTime) & " OutlookAssist - {0}({1})", Frame.GetMethod().Name, sData)
     End Sub

NB : By default, it just display in debug the informations.
To delete the lofs, just uncomment the line " 'oFolder.Items.Item(nMessage).Delete"

----------

