4 Replies - 3825 Views - Last Post: 11 August 2012 - 11:07 AM Rate Topic: -----

#1 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Receive e-mails

Posted 10 August 2012 - 03:07 PM

Hello,
I'm trying to figure out who to create a simple small Mail-Client for my own as a .Net Application, now i'm stuck in no-where.
All i want at this point is to receive response from Pop3 server, which seems to be hell impossible to get.
I've tried all methods and i get response as NULL or nothing from Server i register with like Hotmail (pop3.live.com 995) or Gmail (pop.gmail.com 995)
I have this form :
TextBox1 - Multiline
Button1
The code for connecting to the server (i.e: Gmail.com) in order to see (+ok) response is :
Code:
Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Class Form1
    Dim Network_Stream As NetworkStream
    Dim Read_Stream As StreamReader
Private Sub TextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click
        Dim POP3 As New TcpClient
        Dim PopHost As String = "pop.gmail.com"
        Dim UserName As String = "Myemail@gmail.com"
        Dim Password As String = "MyPassWord"

        Cursor = Cursors.WaitCursor
        POP3.Connect(PopHost, 995)
        Network_Stream = POP3.GetStream()
        Read_Stream = New StreamReader(Network_Stream)
        Dim Return_String As String
        Return_String = Read_Stream.ReadLine + vbCrLf
        TextBox1.Text = Return_String.ToString
        Cursor = Cursors.Default
End Sub
End Class



- I configured Hotmail.com and Gmail.com for POP3 options and they are both are ok.
- I get nothing from the above code, i event tested it with hotmail and still the same nothing.
- I'm supposed to get (+ok) at textbox1 .... but i get nothing at all ...
also by the way : when i used Telnet to connect to both servers, it gave me nothing also ..... i think the problem is same i guess, but i'm not sure

Is This A Good Question/Topic? 0
  • +

Replies To: Receive e-mails

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5535
  • View blog
  • Posts: 11,861
  • Joined: 02-June 10

Re: Receive e-mails

Posted 10 August 2012 - 05:41 PM

You're doing all this when the user clicks on the textbox? Thats just weird. Have you seen buttons? I have serious doubts about the fact that you are clicking into the textbox then trying to set the text of the textbox WHILE you have cursor focus in it. I've never actually tried it because its just goofy.

Did you realize that you never actually send your username and password? I would HOPE you don't get an OK if you don't properly log in.

I think you should stop trying to design a program until you better understand making methods and have a better idea where this should all go.

Do you understand breakpoints and debugging? It sounds like you only know if you get text in the textbox but don't know how to debug and check your true results.

evry1falls: What this shows us is that you aren't familiar with breakpoints and how to debug your own code. Learning to debug one's own code is an essential skill. Sadly, one that apparently few college courses teach. Silly if you ask me.

Placing breakpoints and walking through the code line by line allows you to actually WATCH it execute.

Visualizing what your code does will let you see why it behaves the way it does.

It would be well worth your time to do the tutorials on FAQ 2. A couple hours learning this skill will save you hundreds of hours of confusion in one project alone.


See FAQ # 2. (Click the SHOW button below)



TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated July 2012
Spoiler




Might I also suggest you google "VB.NET email client tutorial"?
Because I see a bunch of guided instruction for how to make something like this. If you're not careful, you just might learn something.
Was This Post Helpful? 0
  • +
  • -

#3 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Re: Receive e-mails

Posted 10 August 2012 - 06:32 PM

First : thanks for your time, and i would like to apologize about the
TextBox1_Click
i was in a hurry so i copied and pasted too quickly to realize that i copied another event with the code i wish to ask about, my bad.So the event is under a button already, thank you very much.
I know how to debug and use breakpoints, doing this under my code gives absolutely nothing, and as you mentioned that i need to send my username and password to the POP3 server, well i thought i might get an answer from the server, then the server would ask about the username or even return [-err] ....
this code is just a part of an application i'm trying to finish, and as long as i did not land anywhere i thought there is something wrong with the logic.
Using Telnet (Telnet pop3.live.com 995) for example doesn't require Username [User] or password [Pass] at first, you just send the server and the port then the server replies asking you to provide the username then the password, i'm sure you already know that 'I hope'.
My code did not return an error [-Err] in the debug window, it returned nothing......
does this have anything to do with the fact that i'm running WinXp Home Edition Sp3 ?!!
but i tried outlook and it worked fine ... so i'm wondering what is wrong !!!
Again thanks for your time, and here is the correct code 'Under the Button' and as i told you i just need to receive an [-ERR] error from the server for now....
Imports System.IO
Imports System.Net.Sockets
Imports System.Text
Imports System.Net.Security
Class Form1
    Dim Network_Stream As NetworkStream
    Dim Read_Stream As StreamReader
    Private Sub CmdDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdDownload.Click
        Dim POP3 As New TcpClient
        Dim PopHost As String = "pop.gmail.com"
        Dim UserName As String = "MyUserName@gmail.com"
        Dim Password As String = "MyPassWord" 'I use 2-step verification so i already have the APP. password fot it

        Cursor = Cursors.WaitCursor
        POP3.Connect(PopHost, 995)
        Network_Stream = POP3.GetStream()
        Read_Stream = New StreamReader(Network_Stream)
        Dim Return_String As String
        Return_String = Read_Stream.ReadLine + vbCrLf
        Console.WriteLine(Return_String)
        Cursor = Cursors.Default
    End Sub
End Class

This post has been edited by evry1falls: 10 August 2012 - 06:33 PM

Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5535
  • View blog
  • Posts: 11,861
  • Joined: 02-June 10

Re: Receive e-mails

Posted 11 August 2012 - 07:15 AM

Quote

does this have anything to do with the fact that i'm running WinXp Home Edition Sp3 ?!!

The fact that you have a 10+ year dead operating system really shouldn't affect anything as email protocols are older than that.
Home Edition just barely falls within the requirements for .NET 4

Again, there are so many tutorials out there on how to build an email client that continuing to try to re-invent the wheel is just silly. You're trying to develop from scratch something that is well documented with a dozen tutorials. The simple fact is what you have here is lacking a lot and based on assumptions you're carrying over from telnet that simply aren't right.

Look at what I found with a quick google of "VB.net receive email example"

Right here on DIC
http://www.dreaminco...receive-emails/

A well documented POP3 class:
http://www.codeproje...ePop3Class.aspx
And another one in both C# and VB.net dating back to 2002 indicating your ancient WinXP system should work fine.
http://www.codeproje...nt-as-a-C-Class

A free library to make it easier
http://www.planet-so...=8275&lngWId=10

Read these articles. Learn from them. Dissect the code to get a better understanding of what you need to do.
Was This Post Helpful? 0
  • +
  • -

#5 evry1falls  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 25-April 12

Re: Receive e-mails

Posted 11 August 2012 - 11:07 AM

Quote

The fact that you have a 10+ year dead operating system really shouldn't affect anything as email protocols are older than that.
Home Edition just barely falls within the requirements for .NET 4

I'm sorry if i can not afford it, it is just the way it is always !

Quote

You're trying to develop from scratch something that is well documented with a dozen tutorials

I'm sorry but ain't it correct that the .Net framework itself doesn't have POP3 server class for e-mails until now ?!!
But i will just look at the proposed tutorials you supported and come back to you......
thanks again for your time ...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1