Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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#)
VB
Dim server As String = "server.com"
Dim port As Integer = 25
Try
    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 FROM:mailFrom@server.com" + CRLF)
    netStream.Write(dataBuffer, 0, dataBuffer.Length)
    ResponseString = reader.ReadLine()

    dataBuffer = BytesFromString("RCPT TO:rcptTo@server.com" + CRLF)
    netStream.Write(dataBuffer, 0, dataBuffer.Length)
    ResponseString = reader.ReadLine()
    MsgBox(ResponseString)

    'QUIT CONNECTION
    dataBuffer = BytesFromString("QUIT" + CRLF)
    netStream.Write(dataBuffer, 0, dataBuffer.Length)
    client.Close()
Catch ex As Exception
    MsgBox(ex.Message)
End Try


Can anyone post why this happens..

Thanks

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
Updated 3-May-17 13:48pm
v4
Comments
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..
[no name] 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"...?
[no name] 3-Aug-12 6:59am    
Could be that or '\n' or '\r' or whatever else the server is setup to be.

1 solution

Hi,
Refer this[^] for the similar discussion.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900