473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

E-mail address check ! who can help me???or any advice

what's the problem??

Remote_Addr = "hotmail.com"
sFrom = "<makefriend8@" & Remote_Addr + ">"

Dim oConnection As New TcpClient()
Try
oConnection.SendTimeout = 3000

oConnection.Connect(mserver, 25) ' msserver is right for
example mx4.HOTMAIL.COM

oStream = oConnection.GetStream()

sResponse = GetData(oStream)
sResponse = SendData(oStream, "HELO " & Remote_Addr & vbCrLf)
sResponse = SendData(oStream, "MAIL FROM: " & sFrom & vbCrLf)

If ValidResponse(sResponse) Then
sResponse = SendData(oStream, "RCPT TO: " & sTo & vbCrLf)

If ValidResponse(sResponse) Then
Return 1 'E-mail address is vaild
Else
Return 2 'wrong address
End If
End If

SendData(oStream, "QUIT" & vbCrLf)
oConnection.Close()
oStream = Nothing
Catch
Return 3 ' why go here?? no matter the address is right or
wrong.

Private Function GetData(ByRef oStream As NetworkStream) As String

Dim bResponse(1024) As Byte
Dim sResponse As String

Dim lenStream As Integer = oStream.Read(bResponse, 0, 1024)
If lenStream 0 Then
sResponse = Encoding.ASCII.GetString(bResponse, 0, 1024)
End If
Return sResponse
End Function
Private Function SendData(ByRef oStream As NetworkStream, ByVal sToSend
As String) As String
Dim sResponse As String

Dim bArray() As Byte = Encoding.ASCII.GetBytes(sToSend.ToCharArray)

oStream.Write(bArray, 0, bArray.Length())
sResponse = GetData(oStream)

Return sResponse
End Function
Private Function ValidResponse(ByVal sResult As String) As Boolean
Dim bResult As Boolean
Dim iFirst As Integer
If sResult.Length 1 Then
iFirst = CType(sResult.Substring(0, 1), Integer)
If iFirst < 3 Then bResult = True
End If
Return bResult
End Function
Jun 27 '08 #1
1 1329
On Apr 15, 9:59 am, "zhang" <makefrie...@163.comwrote:
what's the problem??

Remote_Addr = "hotmail.com"
sFrom = "<makefriend8@" & Remote_Addr + ">"

Dim oConnection As New TcpClient()
Try
oConnection.SendTimeout = 3000

oConnection.Connect(mserver, 25) ' msserver is right for
example mx4.HOTMAIL.COM

oStream = oConnection.GetStream()

sResponse = GetData(oStream)
sResponse = SendData(oStream, "HELO " & Remote_Addr & vbCrLf)
sResponse = SendData(oStream, "MAIL FROM: " & sFrom & vbCrLf)

If ValidResponse(sResponse) Then
sResponse = SendData(oStream, "RCPT TO: " & sTo & vbCrLf)

If ValidResponse(sResponse) Then
Return 1 'E-mail address is vaild
Else
Return 2 'wrong address
End If
End If

SendData(oStream, "QUIT" & vbCrLf)
oConnection.Close()
oStream = Nothing
Catch
Return 3 ' why go here?? no matter the address is right or
wrong.

Private Function GetData(ByRef oStream As NetworkStream) As String

Dim bResponse(1024) As Byte
Dim sResponse As String

Dim lenStream As Integer = oStream.Read(bResponse, 0, 1024)
If lenStream 0 Then
sResponse = Encoding.ASCII.GetString(bResponse, 0, 1024)
End If
Return sResponse
End Function

Private Function SendData(ByRef oStream As NetworkStream, ByVal sToSend
As String) As String
Dim sResponse As String

Dim bArray() As Byte = Encoding.ASCII.GetBytes(sToSend.ToCharArray)

oStream.Write(bArray, 0, bArray.Length())
sResponse = GetData(oStream)

Return sResponse
End Function

Private Function ValidResponse(ByVal sResult As String) As Boolean
Dim bResult As Boolean
Dim iFirst As Integer
If sResult.Length 1 Then
iFirst = CType(sResult.Substring(0, 1), Integer)
If iFirst < 3 Then bResult = True
End If
Return bResult
End Function
Look at your code again....

sResponse = GetData(oStream)
sResponse = SendData(oStream, "HELO " & Remote_Addr &
vbCrLf)
sResponse = SendData(oStream, "MAIL FROM: " & sFrom &
vbCrLf)

If ValidResponse(sResponse) Then
sResponse = SendData(oStream, "RCPT TO: " & sTo &
vbCrLf)

If ValidResponse(sResponse) Then
Return 1 'E-mail address is vaild
Else
Return 2 'wrong address
End If
End If

SendData(oStream, "QUIT" & vbCrLf)
oConnection.Close()
oStream = Nothing
Catch
Return 3 ' why go here?? no matter the address is right
or
wrong.

--------If there is an error in this function, i.e sResult == Nothing
then it will throw an exception -------

Private Function ValidResponse(ByVal sResult As String) As Boolean
Dim bResult As Boolean
Dim iFirst As Integer
If sResult.Length 1 Then
iFirst = CType(sResult.Substring(0, 1), Integer)
If iFirst < 3 Then bResult = True
End If
Return bResult
End Function

which makes the code jump straight to the catch block instantly. But
any line between the words TRY and CATCH that contain an error would
cause the application to jump straight to the catch.
---
Delete the words TRY and CATCH and watch the program run again. This
time it should fail and tell you why and where
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: vishal | last post by:
how can i verify the email address entered by client??? is there any readily available function for that in php or mysql????? else suggest me some links for verifying email address enetered...
9
by: news | last post by:
There's all kinds of ways to validate an email address to make sure it's well formed and whatnot, but what about checking to see if it's a valid e-mail account? Like how you can use checkdnsrr()...
16
by: siliconmike | last post by:
Hi, I'm looking for a reliable script that would connect to a host and somehow determine whether an email address is valid. since getmxrr() only gets the mx records.. Links/pointers ? Mike
17
by: Sue | last post by:
<html> Is there someone here that can help me validate the period as the fourth from the last character in an email address. There is other information and validation on the form I have to do but...
2
by: Cherry | last post by:
Hi, I have an intranet application that should validate the Email Address from the local SMTP Server. I have tried using CDO.Message but that does not seem to have functionality to verify the...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
35
by: Mika M | last post by:
Simple question: Does Framework (1.1) contain any routine to check entered email-address is valid ? It's quite easy to make own code for that purpose, but why to do if Framework (1.1) contain...
3
by: Tom Anderson | last post by:
Hi all, A hoary old chestnut this - any advice on how to syntactically validate an email address? I'd like to support both the display-name-and-angle-bracket and bare-address forms, and to allow...
0
by: comp.lang.php | last post by:
I wrote a method that should check if an email address is valid. In another method I've already checked to see if $_POST exists and is well-formed, so those checks are not necessary in this scope....
4
by: Mike | last post by:
Hi all, In my recent ASP.NET 2.0 appl, I need to verify that the supplied email address is valid or not. So, here's my situation: - In my <profilearea, I created <isVerifiedproperty. - Suppose a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.