OcLee Posted January 16, 2009 Posted January 16, 2009 Hi, I'm Eelco and basicly new to visual basic. I want to create an pop3 connection to receive email. I'm that far that my application will connect to my pop3 account. But then what, how can i recieve what the pop3 does or say, i.e. when i'm connecting with USER user.(myname) pass.(mypass) and everything is ok. Then pop3 will send +OK back, how can I collect that within vb.net? I thirst checked this out with TELNET and there I recieve +ok . Hope you guys can help me with this. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim client As New TcpClient client.Connect("Pop3.whatever.com", 110) If client.Connected = True Then Dim stream As NetworkStream = client.GetStream() Dim data As Byte() = System.Text.Encoding.ASCII.GetBytes("USER user.(myusername) pass.(mypassword)") stream.Write(data, 0, data.Length) MessageBox.Show(" Connected to " & client.ToString) End If End Sub Edit: 21:01 Sorry I was so eager to set my thread that it is in the wrong category, sorry for that. Quote
Administrators PlausiblyDamp Posted January 16, 2009 Administrators Posted January 16, 2009 I think I have some old sample code for POP3 hanging around which I wrote when messing about with sockets, if I can dig it up I'll post it later. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
OcLee Posted January 17, 2009 Author Posted January 17, 2009 Thnx. But I figured it out, sort of. This is what i'm using now. Sub Connect() Dim message As String = String.Empty Dim pop3 As New TcpClient Dim data As [byte]() = System.Text.Encoding.ASCII.GetBytes(Message) Dim response As String = String.Empty Try pop3.Connect(pop3_setting, 110) Dim stream As NetworkStream = pop3.GetStream() data = New [byte](256) {} Dim bytes As Int32 = stream.Read(data, 0, data.Length) response = System.Text.Encoding.ASCII.GetString(data, 0, bytes) Form1.TextBox4.AppendText(response) Catch ex As Exception End Try Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.