Click here to Skip to main content
11,720,547 members (73,589 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET TCP/IP email
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 = "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 30-Jul-12 23:48pm
Edited 2-Aug-12 5:21am
v4
Comments
Kenneth Haugland at 31-Jul-12 6:00am
   
VB and strings is problematic if you use +, you should use & instead
hansoctantan at 31-Jul-12 6:07am
   
same happens..
Wes Aday at 2-Aug-12 11:36am
   
It's stopping on that line because it's probably waiting for a line termination character.
hansoctantan at 3-Aug-12 3:41am
   
this "\r\n"...?
Wes Aday at 3-Aug-12 6:59am
   
Could be that or '\n' or '\r' or whatever else the server is setup to be.
hansoctantan at 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 at 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
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 2,129
1 OriginalGriff 884
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


Advertise | Privacy | Mobile
Web04 | 2.8.150901.1 | Last Updated 2 Aug 2012
Copyright © CodeProject, 1999-2015
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