Can we connect yahoo,msn mail accounts using TCP?
Hi all,
can we connect yahoo,msn mail accounts using Sockets.TcpClient?
I yes how to doi it?what port number I've to use?
My code is like this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' ReadMail("website url", "userid", "password")
End Sub
Function ReadMail(ByVal host As String, ByVal user As String, ByVal pass As String)
' initialise objects
Dim netstream As System.Net.Sockets.NetworkStream
Dim thisResponse As String
Try
tcpC.Connect(host, 110)
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
End Try
netstream = tcpC.GetStream()
thisResponse = GetResponse(netstream)
thisResponse = SendCommand(netstream, "user " & user & vbCrLf)
thisResponse = SendCommand(netstream, "pass " & pass & vbCrLf)
If Not Left(thisResponse, 4) = "-ERR" Then
Response.Write("Logged in OK <BR>")
Else
Response.Write("Error logging in, check your user details and try again<BR>")
Response.Write("<P>" & thisResponse & "</p>")
Response.End()
End If
End Sub
Function SendCommand(ByRef netstream As System.Net.Sockets.NetworkStream, ByVal sToSend As String)
Dim bData() As Byte = Encoding.ASCII.GetBytes(sToSend.ToCharArray)
netstream.Write(bData, 0, bData.Length())
Return GetResponse(netstream)
End Function
Function GetResponse(ByRef netstream As System.Net.Sockets.NetworkStream)
Dim bytes(tcpC.ReceiveBufferSize) As Byte
Dim ret As Integer = netstream.Read(bytes, 0, bytes.Length)
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Return returndata
End Function
********************
It's working for my companys mail id (mailserver is connected in LAN)..if i use yahoo userid and password..its showing message
No connection could be made because the target machine actively refused it
How to do this?
Surya
|