Para quien no quiera bajarse el fichero dejo el code suelto, solo se necesita un Winsock o un CScocket en su defecto
:
Private Sub CommandXP1_Click()
WS.Connect "smtp.google.com", "25"
MousePointer = vbHourglass
CommandXP1.Enabled = False
End Sub
Private Sub Form_Load()
Set WS = New CSocketMaster
Text1.Text = ""
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
WS.GetData Data, vbString, bytesTotal
Select Case Left(Data, 3)
Case "220"
'Si nos saludo nos identificamos.
WS.SendData "HELO 127" & vbCrLf
Case "250"
'Cuando nos saludo cogemos la IP y nos despedimos.
Dim IP As String
IP = Entre(Data, "[", "]")
Text1.Text = IP
WS.SendData "quit" & vbCrLf
Case "221"
WS.CloseSck
MousePointer = vbNormal
CommandXP1.Enabled = True
End Select
End Sub
Public Function Entre(ByVal Str As String, Optional dStart As String, Optional dEnd As String, Optional Length As Long) As String
'Esta funcion obtiene un texto entre dos variables. PD: ES CASE INSENSITIVE ;=)
Dim X1 As Long, X2 As Long
X1 = IIf(dStart = "", 1, InStr(1, LCase$(Str), LCase$(dStart)) + Len(dStart))
If X1 > 0 Then
If dEnd = "" Then
Entre = Mid$(Str, X1)
Else
X2 = InStr(X1, LCase$(Str), LCase$(dEnd)) - X1
If X2 > 0 Then
Entre = Mid$(Str, X1, X2)
Else
Entre = ""
End If
End If
Else
Entre = ""
End If
If Length > 0 And Entre <> "" Then Entre = Left$(Entre, Length)
End Function