I have a very simple little program that connects to our email server to
send out emails. When I compiled it with .VS2003 (net 1.1), it works fine.
with VS2005 (.net 2.0), it hangs on the last ReadInfo
Any suggestions? thanks!
Public Function send2() As String
Dim err As String = ""
soc = ConnectSocket(S erver, 25)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("HELO ", Err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("MAIL FROM:" & From, err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("RCPT TO:" & "RTorcellini@my domain.com", err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("DATA ", err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("This is a test" & vbCrLf & "." & vbCrLf, err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("QUIT ", err)
Debug.Write(Rea dInfo(err) & vbCrLf) 'CODE HANGS HERE- SEE BELOW
soc.Close()
End Function
Private Function WriteInfo(ByVal Info As String, ByRef err As String) As
String
Dim bytes As Byte()
Dim ASCII As Encoding = Encoding.ASCII
bytes = ASCII.GetBytes( Info & vbCrLf)
soc.Send(bytes, bytes.Length, 0)
End Function
Private Function ReadInfo(ByRef Err As String) As String
Try
Dim bytes As Int32
Dim RecvBytes(256) As Byte
Dim ASCII As Encoding = Encoding.ASCII
bytes = soc.Receive(Rec vBytes, RecvBytes.Lengt h, 0) 'HANGS HERE
ON LAST ReadInfo
Return ASCII.GetString (RecvBytes, 0, bytes)
Catch ex As Exception
Err = ex.Message
End Try
End Function
send out emails. When I compiled it with .VS2003 (net 1.1), it works fine.
with VS2005 (.net 2.0), it hangs on the last ReadInfo
Any suggestions? thanks!
Public Function send2() As String
Dim err As String = ""
soc = ConnectSocket(S erver, 25)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("HELO ", Err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("MAIL FROM:" & From, err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("RCPT TO:" & "RTorcellini@my domain.com", err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("DATA ", err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("This is a test" & vbCrLf & "." & vbCrLf, err)
Debug.Write(Rea dInfo(err) & vbCrLf)
WriteInfo("QUIT ", err)
Debug.Write(Rea dInfo(err) & vbCrLf) 'CODE HANGS HERE- SEE BELOW
soc.Close()
End Function
Private Function WriteInfo(ByVal Info As String, ByRef err As String) As
String
Dim bytes As Byte()
Dim ASCII As Encoding = Encoding.ASCII
bytes = ASCII.GetBytes( Info & vbCrLf)
soc.Send(bytes, bytes.Length, 0)
End Function
Private Function ReadInfo(ByRef Err As String) As String
Try
Dim bytes As Int32
Dim RecvBytes(256) As Byte
Dim ASCII As Encoding = Encoding.ASCII
bytes = soc.Receive(Rec vBytes, RecvBytes.Lengt h, 0) 'HANGS HERE
ON LAST ReadInfo
Return ASCII.GetString (RecvBytes, 0, bytes)
Catch ex As Exception
Err = ex.Message
End Try
End Function
Comment