here is the whole sub routine until it breaks.
Public Sub POCProces(poc)
Dim queryresult As String = ""
Dim POCDetails() As String = poc.Split(",")
Dim hostname = "outlook.office365.com"
Dim Server = POCDetails(0)
Dim Username = POCDetails(1)
Dim Password = POCDetails(2)
Dim smtpdomain = POCDetails(3)
Dim PODAddress = POCDetails(4)
Dim options As New ParallelOptions()
Dim messagesperthread = My.Settings.messagesperthread
options.MaxDegreeOfParallelism = My.Settings.TotalThreads
Dim sresult As String = ""
Using imap As New Rebex.Net.Imap()
Dim mydb As New mySqlDB
mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, POC) values ('" & Server & "','Perf-Log','POC Started','" & Username & "')", sresult)
Try
mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('" & Server & "','error','connected fine',' ')", sresult)
imap.Connect(hostname, SslMode.Implicit)
imap.Login(Username, Password)
imap.SelectFolder("Inbox")
Catch ex As Exception
'mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('" & Server & "','error','" & ex.Message & "',' ')", sresult)
mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('" & Server & "','error','Going to exit sub - cant connct','" & ex.ToString() & "')", sresult)
Exit Sub
End Try