Last active
December 14, 2015 15:49
-
-
Save facebookegypt/5110983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Starts | |
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 As String | |
Dim Parts() As String | |
Dim m_buffer() As Byte | |
Dim StatResp As String | |
Private Sub CmdDownload_Click(ByVal sender As System.Object, _ | |
ByVal e As System.EventArgs) Handles CmdDownload.Click | |
PopHost = TxtHost.Text | |
UserName = TxtUsrNm.Text | |
Password = TxtPass.Text | |
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()) | |
StatResp = ListBox1.Items(3).ToString | |
'Get Messages count | |
Dim server_Stat(2) As String | |
server_Stat = StatResp.Split(" ") | |
MsgCount.Text = server_Stat(1) | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment