Skip to content

Instantly share code, notes, and snippets.

@facebookegypt
Created March 7, 2013 19:08
Show Gist options
  • Save facebookegypt/5110818 to your computer and use it in GitHub Desktop.
Save facebookegypt/5110818 to your computer and use it in GitHub Desktop.
Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Imports System.Net.Security
Imports System.Net
Class Form1
Dim PopHost As String
Dim UserName As String
Dim Password As String
Dim PortNm As Integer
Dim POP3 As New TcpClient
Dim Read_Stream As StreamReader
Dim NetworkS_tream As NetworkStream
Dim m_sslStream As SslStream
Dim server_Command, Sent_Val As String
Dim m_buffer() As Byte
Private Sub CmdDownload_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CmdDownload.Click
PopHost = TxtHost.Text.ToString()
UserName = TxtUsrNm.Text.ToString
Password = TxtPass.Text.ToString
PortNm = TxtPort.Text
Cursor = Cursors.WaitCursor
POP3.Connect(PopHost, Integer.Parse(PortNm))
Login
Cursor = Cursors.Default
End Sub
Sub Login()
NetworkS_tream = POP3.GetStream()
m_sslStream = New SslStream(NetworkS_tream)
m_sslStream.AuthenticateAsClient(PopHost)
Read_Stream = New StreamReader(m_sslStream)
ListBox1.Items.Add(Read_Stream.ReadLine())
server_Command = "USER " + UserName + vbCrLf
m_buffer = System.Text.Encoding.ASCII.GetBytes(server_Command.ToCharArray())
m_sslStream.Write(m_buffer, 0, m_buffer.Length)
ListBox1.Items.Add(Read_Stream.ReadLine())
server_Command = "PASS " + Password + vbCrLf
m_buffer = System.Text.Encoding.ASCII.GetBytes(server_Command.ToCharArray())
m_sslStream.Write(m_buffer, 0, m_buffer.Length)
ListBox1.Items.Add(Read_Stream.ReadLine())
'Send STAT command to get information ie: number of mail and size
server_Command = "STAT " + vbCrLf
m_buffer = System.Text.Encoding.ASCII.GetBytes(server_Command.ToCharArray())
m_sslStream.Write(m_buffer, 0, m_buffer.Length)
ListBox1.Items.Add(Read_Stream.ReadLine())
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment