Searching POP3 accounts for bounced emails with vb.net

5. Put it all together in our main method

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
''' <summary>
''' This will take a inputted file that contains username, password, pop server, and port seperated by a TAB and get all bounced emails from it,
''' outputting the final list to a text file
''' </summary>
''' <remarks></remarks>
Sub Main()
 
  'first we need to open our list of pop3 accounts, returning an error if we can not
  Dim filename As String = "accounts.txt"
  If Load_POP3(filename) = False Then
    Console.WriteLine("There was an error accessing the """ & filename & """ file. Please make sure it exists and that no other programs are using this file.")
    Exit Sub
  End If
 
  'We need to open a new file for writing to
  Dim savedFile As String = Now.ToString("MM-dd-yyyy HH-mm-ss") & ".txt"
  writer = New IO.StreamWriter(savedFile, False)
 
  'Once accounts are loaded, process each account until there are no more
  While accounts.Count > 0
 
    'Get our next account, and remove it from the accounts list so we do not reprocess it
    Dim current As Account = accounts.ElementAt(0)
    accounts.RemoveAt(0)
 
    'Get the bounced emails for this account
    Console.WriteLine("Processing [" & current.username & "]. " & FormatNumber(accounts.Count, 0) & " pending.")
    Dim err As String = ""
    Dim success As Boolean = Process_Account(current, 1, err)
 
    'If this failed say why
    If success = False Then Console.WriteLine("-- Error: " & err)
 
    'Write a blank line to break us up
    Console.WriteLine()
 
  End While
 
  'Close our writer and say complete
  writer.Close()
  Console.WriteLine("Process completed with " & FormatNumber(bounceCount, 0) & " bounced emails.")
  Console.WriteLine("We have saved your bounced emails to " & savedFile & ". Press enter to close this window.")
  Console.ReadLine()
 
End Sub

6. Summary / Source Code

That’s it! you now have a working console application to check for bounced requests!

You can download the solution files below:

Bounced Email Dumper

Pages:
  1. very nice website, enjoy the way you write, you definitely do hold a flair for writing, will be viewing this website quite often

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">