Table Of Contents:
4. Code our method to process a single account
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | ''' <summary> ''' This will get all the bounce requests for a specific account ''' </summary> ''' <param name="acc"></param> ''' <param name="minimum_level">The min level we will look for when deciding if it's a bounced email</param> ''' <param name="err">if there is an error, it will be held here</param> ''' <returns></returns> ''' <remarks></remarks> Private Function Process_Account(acc As Account, ByVal minimum_level As Integer, ByRef err As String) As Boolean 'Use a try so that we can catch errors Try 'Holds how many people bounced Dim localBounceCount As Integer = 0 'Connect to the server writing how many emails we have left to process Dim pop As New Pop3Client pop.Connect(acc.server, acc.port, acc.username, acc.password) Dim mailCount As Integer = pop.MessageCount Console.WriteLine("-- We have " & FormatNumber(mailCount, 0) & " emails to process") 'Loop each mail For i As Integer = 1 To mailCount 'Get the message and bounce info for this message (if msg is nothing for any reason, continue) Dim msg As Message = pop.RetrieveMessageObject(i) 'If bounced is nothing, contine Dim bounced As BounceResult = msg.GetBounceStatus("bouncedSignatures.xml") Console.WriteLine("-- Checking email " & FormatNumber(i, 0) & " of " & FormatNumber(mailCount, 0) & " (" & FormatNumber((i / mailCount) * 100, 3) & "%)") 'If bounce level is >= to our min leve, add it to our list and increase our counters If bounced.Level >= minimum_level And bounced.Email <> "" Then writer.WriteLine(bounced.Email & vbTab & bounced.Level) localBounceCount += 1 bounceCount += 1 End If Next 'Write how many bounced emails we found and return true Console.WriteLine("-- We found " & FormatNumber(localBounceCount, 0) & " bounced emails") Return True 'If we have a pop3 exception return it Catch pexp As Pop3Exception err = pexp.Message Return False 'Return the generate exception Catch ex As Exception err = ex.Message Return False End Try 'We completed ok so return true Return True End Function |
very nice website, enjoy the way you write, you definitely do hold a flair for writing, will be viewing this website quite often