Click here to Skip to main content
13,192,426 members (46,712 online)
Rate this:
Please Sign up or sign in to vote.
Hi everyone,
I'm creating a program that verify an email if it exists. I found a code on doing this but when I try using it, the runtime stops "ResponseString = reader.ReadLine()" when the program reading the response string.

Below is the code (I just converted this t VB.NET the original code is C#)
        Dim server As String = ""
        Dim port As Integer = 25
            Dim client As New TcpClient(server, port)
            Dim CRLF As String = "\r\n"
            Dim dataBuffer As Byte()
            Dim ResponseString As String
            Dim netStream As NetworkStream = client.GetStream()
            Dim reader As StreamReader = New StreamReader(netStream)
            'I put a breakoint here
            ResponseString = reader.ReadLine()
            dataBuffer = BytesFromString("HELO HI" + CRLF)
            netStream.Write(dataBuffer, 0, dataBuffer.Length)
            'Code Stops Here
            ResponseString = reader.ReadLine()
            dataBuffer = BytesFromString("MAIL" + CRLF)
            netStream.Write(dataBuffer, 0, dataBuffer.Length)
            ResponseString = reader.ReadLine()
            dataBuffer = BytesFromString("RCPT" + CRLF)
            netStream.Write(dataBuffer, 0, dataBuffer.Length)
            ResponseString = reader.ReadLine()
            'QUIT CONNECTION 
            dataBuffer = BytesFromString("QUIT" + CRLF)
            netStream.Write(dataBuffer, 0, dataBuffer.Length)
        Catch ex As Exception
        End Try

Can anyone post why this happens..


Still can't find an answer....
The below source is to send, but I want to check if email exists in Mail Server or not...
Posted 30-Jul-12 23:48pm
Updated 3-May-17 13:48pm
Kenneth Haugland 31-Jul-12 6:00am
VB and strings is problematic if you use +, you should use & instead
hansoctantan 31-Jul-12 6:07am
same happens..
Wes Aday 2-Aug-12 11:36am
It's stopping on that line because it's probably waiting for a line termination character.
hansoctantan 3-Aug-12 3:41am
this "\r\n"...?
Wes Aday 3-Aug-12 6:59am
Could be that or '\n' or '\r' or whatever else the server is setup to be.
hansoctantan 6-Aug-12 7:46am
I try using different termination character (\n, \r, \r\n, \n\r, \r\n\r) but still same happened...
Wes Aday 6-Aug-12 9:06am
Probably because you are guessing instead of finding out. Check to see if anything at all is coming back before you try and read it. Debug it. Find out what the server is actually sending back.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Refer this[^] for the similar discussion.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171017.2 | Last Updated 3 May 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100