Page 1 of 1
Programa que recibe e-mails?
Posted: Mon Oct 03, 2011 5:03 pm
by karinha
Señores, alguien tiene un ejemplo de programa que recibe e-mails? Tengo que recuperar mi correo electrónico directamente desde mi programa, es posible?
Gracias.
Saludos.
Re: Programa que recibe e-mails?
Posted: Thu Oct 06, 2011 12:41 pm
by karinha
up
Re: Programa que recibe e-mails?
Posted: Mon Oct 10, 2011 11:57 pm
by Alvaro Urdaneta
Hola karinha, a mi me funciona asi:
Code: Select all
// Testing FiveWin new Internet incoming mail (POP3 protocol) Class
#include "FiveWin.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
local oBar
DEFINE WINDOW oWnd TITLE "Receiving Internet Mail from FiveWin"
DEFINE BUTTONBAR oBar _3D OF oWnd
DEFINE BUTTON OF oBar ACTION GetMail() TOOLTIP "Get Mail"
SET MESSAGE OF oWnd TO "Ready" NOINSET DATE TIME KEYBOARD
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function GetMail()
local oInMail
local cIp
if WsaStartup() == 0
cIp := gethostbyname( "pop.gmail.com" )
WsaCleanUp()
endif
oWnd:SetMsg( "Geting Internet email..." )
oInMail = TPop4():New( cIp,, "miusuario", "miclave" )
oInMail:bConnecting = { || oWnd:SetMsg( "Connecting to " + cIp ) }
oInMail:bConnected = { || oWnd:SetMsg( "Connected" ) }
oInMail:bDone = { || ReadEmails( oInMail ) }
oInMail:GetMail()
return nil
//----------------------------------------------------------------------------//
function ReadEmails( oInMail )
local n, cTxt := ""
MsgInfo( "Total emails: " + Str( Len( oInMail:aMsgs ) ) )
for n = 1 to Len( oInMail:aMsgs )
cTxt += oInMail:aMsgs[ n ] + CRLF + "--- FINAL DE ESTE MAIL ---" + CRLF
next
memowrit( "email.txt", cTxt )
return nil
//----------------------------------------------------------------------------//
Re: Programa que recibe e-mails?
Posted: Tue Oct 11, 2011 12:19 pm
by karinha
Gracias Alvaro, voy probar y comento.
Regards, saludos.
Re: Programa que recibe e-mails?
Posted: Tue Oct 11, 2011 4:02 pm
by karinha
Alvaro, donde está: TPOP4() ???
Gracias
Re: Programa que recibe e-mails?
Posted: Wed Oct 12, 2011 1:22 am
by Alvaro Urdaneta
Karinha, yo uso xHarbour, posiblemente te falta alguna lib, el build que utilizo es este:
Code: Select all
@ECHO OFF
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ FiveWin for xHarbour 8.09 - Sep. 2008 xHarbour development power ³Ü
ECHO ³ (c) FiveTech, 1993-2008 for Microsoft Windows 95/98/NT/2000/ME/XP/Vista ³Û
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ECHO ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST
ECHO Compiling...
set hdir=\xharbour
set bcdir=\bcc
%hdir%\bin\harbour %1 /n /i..\include;%hdir%\include /w /p %2 %3 > clip.log
@type clip.log
IF ERRORLEVEL 1 PAUSE
IF ERRORLEVEL 1 GOTO EXIT
echo -O2 -e%1.exe -I%hdir%\include;\fwh\include %1.c > b32.bc
%bcdir%\bin\bcc32 -M -c -v @b32.bc
:ENDCOMPILE
IF EXIST %1.rc %bcdir%\bin\brc32 -r %1
echo c0w32.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo \fwh\lib\Fivehx.lib \fwh\lib\FiveHC.lib + >> b32.bc
echo %hdir%\lib\rtl.lib + >> b32.bc
echo %hdir%\lib\vm.lib + >> b32.bc
echo %hdir%\lib\gtgui.lib + >> b32.bc
echo %hdir%\lib\lang.lib + >> b32.bc
echo %hdir%\lib\macro.lib + >> b32.bc
echo %hdir%\lib\rdd.lib + >> b32.bc
echo %hdir%\lib\dbfntx.lib + >> b32.bc
echo %hdir%\lib\dbfcdx.lib + >> b32.bc
echo %hdir%\lib\dbffpt.lib + >> b32.bc
echo %hdir%\lib\hbsix.lib + >> b32.bc
echo %hdir%\lib\debug.lib + >> b32.bc
echo %hdir%\lib\common.lib + >> b32.bc
echo %hdir%\lib\pp.lib + >> b32.bc
echo %hdir%\lib\pcrepos.lib + >> b32.bc
echo tpop4.obj + >> b32.bc
rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc
echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc
echo %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib + >> b32.bc
echo %bcdir%\lib\psdk\nddeapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bc
IF EXIST %1.res echo %1.res >> b32.bc
rem uncomment this line to use the debugger and comment the following one
rem %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bc
%bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built
%1
GOTO EXIT
ECHO
rem delete temporary files
@del %1.c
:LINKERROR
ECHO * There are errors
GOTO EXIT
:SINTAX
ECHO SYNTAX: Build [Program] {-- No especifiques la extensi¢n PRG
ECHO {-- Don't specify .PRG extension
GOTO EXIT
:NOEXIST
ECHO The specified PRG %1 does not exist
:EXIT
Re: Programa que recibe e-mails?
Posted: Wed Oct 12, 2011 6:42 pm
by theotokos
Mi amigo, se utiliza un archivo llamado TPOP4.obj, es probablemente la clase resposanvel, puede que nos envían? Gracias! Gracias
Re: Programa que recibe e-mails?
Posted: Thu Oct 13, 2011 12:04 am
by Alvaro Urdaneta
tPop4 es la misma tPop3 de SOURCE\CLASSES:
Code: Select all
// FiveWin Internet incomming mail Class
#include "FiveWin.ch"
// different session status
// CONNECT
#define ST_CONNECTING 1
#define ST_IDENTIFY1 2
#define ST_IDENTIFY2 3
#define ST_STAT 99
#define ST_REQLIST 4
#define ST_IDENTIFY4 5
#define ST_IDENTIFY5 6
#define ST_SENDBODY 7
#define ST_SENDQUIT 8
#define ST_ENDED 10
#define ST_REQNEXT 98
#define ST_REQMSG 96
#define ST_DELMSG 97
// STOR
#define ST_STOR_PORT "ST_PORT"
#define ST_STOR_OPENCONN "ST_OPENCONN"
#define ST_STOR_START "ST_START"
#define CONNECT_OK "220"
#define HELLO_OK "250"
#define MAILFROM_OK "250"
#define MAILTO_OK "250"
#define DATA_OK "354"
#define LOGIN_OK "230"
#define MSG_OK "250"
#define CLOSE_OK "221"
#define ENDMSG "."
#define ST_NOOP 6
#define ST_OK "+OK"
//----------------------------------------------------------------------------//
CLASS TPop4
DATA oSocket // socket used during the Control session
DATA nPort
DATA User
DATA Pass
DATA lOk
DATA aMsgs
DATA nAtMsg
DATA cIPServer // IP of the mail server
DATA AllOk
DATA nStatus // Temporary session status
DATA lDelMsgs
DATA bConnecting // Action to perform while trying to connect to the server
DATA bConnected // Action to perform when already connected to the server
DATA bDone // Action to perform when Msgs have been retrieved
METHOD New( cIPServer, nPort, User, Pass ) CONSTRUCTOR
METHOD GetMail()
METHOD OnRead( oSocket )
METHOD LogError( cData, oSocket )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cIPServer, nPort, User, Pass ) CLASS TPop4
DEFAULT nPort := 110
::AllOk := .f.
::cIPServer := cIPServer
::User := User
::Pass := Pass
::nStatus := ST_CONNECTING
::nPort := nPort
::lDelMsgs := .t.
return self
//----------------------------------------------------------------------------//
METHOD GetMail() CLASS TPop4
::oSocket := TSocket():New( ::nPort )
::oSocket:bRead = { | o | ::OnRead( o ) }
::oSocket:Connect( ::cIpServer )
return Self
//----------------------------------------------------------------------------//
METHOD OnRead( oSocket ) CLASS TPop4
local cData := oSocket:GetData()
local rCode := SubStr( cData, 1 ,3 )
local cMsg := SubStr( cData, 3 )
local cCommand := ""
local n
//msginfo( rCode )
//msginfo( cMsg )
do case
case ::nStatus == ST_CONNECTING
if rCode == ST_OK
cCommand = "USER " + ::User + CRLF
::nStatus = ST_IDENTIFY1
if ::bConnecting != nil
Eval( ::bConnecting, Self )
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_IDENTIFY1
if rCode == ST_OK
cCommand = "PASS " + ::Pass + CRLF
::nStatus = ST_IDENTIFY2
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_IDENTIFY2
if rCode == ST_OK
cCommand = "STAT " + CRLF
::nStatus = ST_STAT
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_STAT
if rCode == ST_OK
if ::bConnected != nil
Eval( ::bConnected, Self )
endif
cData = StrTran( cData, " ", "&" ) + "&"
::aMsgs := Array( Val( StrToken( cData, 2, "&" ) ) )
for n = 1 to Len( ::aMsgs )
::aMsgs[ n ] = ""
next
if Len( ::aMsgs ) == 0
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
else
::nAtMsg = 1
cCommand = "RETR " + AllTrim( Str( 1, 4, 0 ) )+ CRLF
::nStatus = ST_REQMSG
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_DELMSG
if rCode == ST_OK
if ::nAtMsg < Len( ::aMsgs )
cCommand = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_REQMSG
else
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_REQMSG
if ::nAtMsg <= Len( ::aMsgs )
::aMsgs[ ::nAtMsg ] += cData
if At( Chr( 13 ) + Chr( 10 ) + "." + Chr( 13 ) + Chr( 10 ), cData ) > 0
if ::lDelMsgs
cCommand = "DELE " + AllTrim( Str( ::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_DELMSG
else
cCommand = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_REQMSG
endif
else
::nStatus = ST_REQMSG
endif
else
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
::AllOk = .t.
endif
case ::nStatus == ST_SENDQUIT
if rCode == ST_OK
cCommand = ""
oSocket:End()
::nStatus = ST_ENDED
::AllOk = .t.
else
::LogError( cData, oSocket )
endif
endcase
msginfo( cCommand )
if ! Empty( cCommand )
oSocket:SendData( cCommand )
if cCommand == "QUIT" + CRLF
if ::bDone != nil
Eval( ::bDone, Self )
endif
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD LogError( cData, oSocket ) CLASS TPop4
oSocket:End()
LogFile( "MailErr.log", { ::nStatus,cData } )
::AllOk := .f.
return nil
//----------------------------------------------------------------------------//
Re: Programa que recibe e-mails?
Posted: Thu Oct 13, 2011 1:43 am
by cuatecatl82
Se ve interesante el ejemplo, pero desafortunadamente no me funciono, lo probe con una cuenta de gmail y de hotmail, pero en ninguna me pudo regresar la información de correo, algo talvez hize mal.
Revisando el código y los mensajes en la barra de mensajes, se queda en: "
Geting Internet email..."
Code: Select all
oWnd:SetMsg( "Geting Internet email..." )
oInMail = TPop4():New( cIp,, "danyleon82@gmail.com", "mipassword" )
oInMail:bConnecting = { || oWnd:SetMsg( "Connecting to " + cIp ) }
oInMail:bConnected = { || oWnd:SetMsg( "Connected" ) }
oInMail:bDone = { || ReadEmails( oInMail ) }
oInMail:GetMail()
No cambian los mensajes a "Conectando a IP" o "Conectado", seguramente algo hay mal en la declaración de mis variables de la Clase TPop4, probe con poner solo el nombre de usuario sin "@gmail.com", pero no funciono...
A alguien le funcionó, se agradecería si comentaran como hecharlo a andar, se ve prometedor..
Saludos..
Re: Programa que recibe e-mails?
Posted: Thu Oct 13, 2011 2:00 am
by Alvaro Urdaneta
Victor, a mi me funciona el ejemplo tal cual está publicado con gmail, yo uso fwh8.09 y xHarbour 1.1.0, prueba con el mismo ejemplo, mismo build y el mismo Pop4.prg, debes poner las comillas " en usuario y password. El prg es el testpop3.prg de samples con alguna variacion y el Tpop4 es el mismo tPop3 original de sources, yo le puse otro nombre para hacer algunas pruebas
Testpop3.prg
Code: Select all
// Testing FiveWin new Internet incoming mail (POP3 protocol) Class
#include "FiveWin.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
local oBar
DEFINE WINDOW oWnd TITLE "Receiving Internet Mail from FiveWin"
DEFINE BUTTONBAR oBar _3D OF oWnd
DEFINE BUTTON OF oBar ACTION GetMail() TOOLTIP "Get Mail"
SET MESSAGE OF oWnd TO "Ready" NOINSET DATE TIME KEYBOARD
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//
function GetMail()
local oInMail
local cIp
if WsaStartup() == 0
cIp := gethostbyname( "pop.gmail.com" ) //"mail.google.com" )
WsaCleanUp()
endif
oWnd:SetMsg( "Geting Internet email..." )
oInMail = TPop4():New( cIp,, "sistemas.amc@gmail.com", "miclave" ) // mail server IP
oInMail:bConnecting = { || oWnd:SetMsg( "Connecting to " + cIp ) }
oInMail:bConnected = { || oWnd:SetMsg( "Connected" ) }
oInMail:bDone = { || ReadEmails( oInMail ) }
// oInmail:nStatus := 99 //ST_CONNECTING
oInMail:GetMail()
return nil
//----------------------------------------------------------------------------//
function ReadEmails( oInMail )
local n, cTxt := ""
MsgInfo( "Total emails: " + Str( Len( oInMail:aMsgs ) ) )
for n = 1 to Len( oInMail:aMsgs )
cTxt += oInMail:aMsgs[ n ] + CRLF + "FIN ------- FIN" + CRLF
next
memowrit( "pop3.txt", cTxt )
return nil
//----------------------------------------------------------------------------//
buildx.bat:
Code: Select all
@ECHO OFF
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ FiveWin for xHarbour 8.09 - Sep. 2008 xHarbour development power ³Ü
ECHO ³ (c) FiveTech, 1993-2008 for Microsoft Windows 95/98/NT/2000/ME/XP/Vista ³Û
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ECHO ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST
ECHO Compiling...
set hdir=\xharbour
set bcdir=\bcc
%hdir%\bin\harbour %1 /n /i..\include;%hdir%\include /w /p %2 %3 > clip.log
@type clip.log
IF ERRORLEVEL 1 PAUSE
IF ERRORLEVEL 1 GOTO EXIT
echo -O2 -e%1.exe -I%hdir%\include;\fwh\include %1.c > b32.bc
%bcdir%\bin\bcc32 -M -c -v @b32.bc
:ENDCOMPILE
IF EXIST %1.rc %bcdir%\bin\brc32 -r %1
echo c0w32.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo \fwh\lib\Fivehx.lib \fwh\lib\FiveHC.lib + >> b32.bc
echo %hdir%\lib\rtl.lib + >> b32.bc
echo %hdir%\lib\vm.lib + >> b32.bc
echo %hdir%\lib\gtgui.lib + >> b32.bc
echo %hdir%\lib\lang.lib + >> b32.bc
echo %hdir%\lib\macro.lib + >> b32.bc
echo %hdir%\lib\rdd.lib + >> b32.bc
echo %hdir%\lib\dbfntx.lib + >> b32.bc
echo %hdir%\lib\dbfcdx.lib + >> b32.bc
echo %hdir%\lib\dbffpt.lib + >> b32.bc
echo %hdir%\lib\hbsix.lib + >> b32.bc
echo %hdir%\lib\debug.lib + >> b32.bc
echo %hdir%\lib\common.lib + >> b32.bc
echo %hdir%\lib\pp.lib + >> b32.bc
echo %hdir%\lib\pcrepos.lib + >> b32.bc
echo tpop4.obj + >> b32.bc
rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc
echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc
echo %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib + >> b32.bc
echo %bcdir%\lib\psdk\nddeapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bc
IF EXIST %1.res echo %1.res >> b32.bc
rem uncomment this line to use the debugger and comment the following one
rem %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bc
%bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built
%1
GOTO EXIT
ECHO
rem delete temporary files
@del %1.c
:LINKERROR
ECHO * There are errors
GOTO EXIT
:SINTAX
ECHO SYNTAX: Build [Program] {-- No especifiques la extensi¢n PRG
ECHO {-- Don't specify .PRG extension
GOTO EXIT
:NOEXIST
ECHO The specified PRG %1 does not exist
:EXIT
pop4:
Code: Select all
// FiveWin Internet incomming mail Class
#include "FiveWin.ch"
// different session status
// CONNECT
#define ST_CONNECTING 1
#define ST_IDENTIFY1 2
#define ST_IDENTIFY2 3
#define ST_STAT 99
#define ST_REQLIST 4
#define ST_IDENTIFY4 5
#define ST_IDENTIFY5 6
#define ST_SENDBODY 7
#define ST_SENDQUIT 8
#define ST_ENDED 10
#define ST_REQNEXT 98
#define ST_REQMSG 96
#define ST_DELMSG 97
// STOR
#define ST_STOR_PORT "ST_PORT"
#define ST_STOR_OPENCONN "ST_OPENCONN"
#define ST_STOR_START "ST_START"
#define CONNECT_OK "220"
#define HELLO_OK "250"
#define MAILFROM_OK "250"
#define MAILTO_OK "250"
#define DATA_OK "354"
#define LOGIN_OK "230"
#define MSG_OK "250"
#define CLOSE_OK "221"
#define ENDMSG "."
#define ST_NOOP 6
#define ST_OK "+OK"
//----------------------------------------------------------------------------//
CLASS TPop4
DATA oSocket // socket used during the Control session
DATA nPort
DATA User
DATA Pass
DATA lOk
DATA aMsgs
DATA nAtMsg
DATA cIPServer // IP of the mail server
DATA AllOk
DATA nStatus // Temporary session status
DATA lDelMsgs
DATA bConnecting // Action to perform while trying to connect to the server
DATA bConnected // Action to perform when already connected to the server
DATA bDone // Action to perform when Msgs have been retrieved
METHOD New( cIPServer, nPort, User, Pass ) CONSTRUCTOR
METHOD GetMail()
METHOD OnRead( oSocket )
METHOD LogError( cData, oSocket )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cIPServer, nPort, User, Pass ) CLASS TPop4
DEFAULT nPort := 110
::AllOk := .f.
::cIPServer := cIPServer
::User := User
::Pass := Pass
::nStatus := ST_CONNECTING
::nPort := nPort
::lDelMsgs := .t.
return self
//----------------------------------------------------------------------------//
METHOD GetMail() CLASS TPop4
::oSocket := TSocket():New( ::nPort )
::oSocket:bRead = { | o | ::OnRead( o ) }
::oSocket:Connect( ::cIpServer )
return Self
//----------------------------------------------------------------------------//
METHOD OnRead( oSocket ) CLASS TPop4
local cData := oSocket:GetData()
local rCode := SubStr( cData, 1 ,3 )
local cMsg := SubStr( cData, 3 )
local cCommand := ""
local n
//msginfo( rCode )
//msginfo( cMsg )
do case
case ::nStatus == ST_CONNECTING
if rCode == ST_OK
cCommand = "USER " + ::User + CRLF
::nStatus = ST_IDENTIFY1
if ::bConnecting != nil
Eval( ::bConnecting, Self )
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_IDENTIFY1
if rCode == ST_OK
cCommand = "PASS " + ::Pass + CRLF
::nStatus = ST_IDENTIFY2
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_IDENTIFY2
if rCode == ST_OK
cCommand = "STAT " + CRLF
::nStatus = ST_STAT
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_STAT
if rCode == ST_OK
if ::bConnected != nil
Eval( ::bConnected, Self )
endif
cData = StrTran( cData, " ", "&" ) + "&"
::aMsgs := Array( Val( StrToken( cData, 2, "&" ) ) )
for n = 1 to Len( ::aMsgs )
::aMsgs[ n ] = ""
next
if Len( ::aMsgs ) == 0
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
else
::nAtMsg = 1
cCommand = "RETR " + AllTrim( Str( 1, 4, 0 ) )+ CRLF
::nStatus = ST_REQMSG
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_DELMSG
if rCode == ST_OK
if ::nAtMsg < Len( ::aMsgs )
cCommand = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_REQMSG
else
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
endif
else
::LogError( cData, oSocket )
endif
case ::nStatus == ST_REQMSG
if ::nAtMsg <= Len( ::aMsgs )
::aMsgs[ ::nAtMsg ] += cData
if At( Chr( 13 ) + Chr( 10 ) + "." + Chr( 13 ) + Chr( 10 ), cData ) > 0
if ::lDelMsgs
cCommand = "DELE " + AllTrim( Str( ::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_DELMSG
else
cCommand = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
::nStatus = ST_REQMSG
endif
else
::nStatus = ST_REQMSG
endif
else
cCommand = "QUIT" + CRLF
::nStatus = ST_SENDQUIT
::AllOk = .t.
endif
case ::nStatus == ST_SENDQUIT
if rCode == ST_OK
cCommand = ""
oSocket:End()
::nStatus = ST_ENDED
::AllOk = .t.
else
::LogError( cData, oSocket )
endif
endcase
msginfo( cCommand )
if ! Empty( cCommand )
oSocket:SendData( cCommand )
if cCommand == "QUIT" + CRLF
if ::bDone != nil
Eval( ::bDone, Self )
endif
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD LogError( cData, oSocket ) CLASS TPop4
oSocket:End()
LogFile( "MailErr.log", { ::nStatus,cData } )
::AllOk := .f.
return nil
//----------------------------------------------------------------------------//
Re: Programa que recibe e-mails?
Posted: Thu Oct 13, 2011 3:29 am
by cuatecatl82
Gracias Alvaro por la pronta respuesta,desgraciadamente no puedo probarlo, sigue igual, pude crearlo con los codigos y el buidx.bat que me mandaste, lo crea, pero al correrlo no recibe correo, creo que el problema esta en mi cuenta de gmail, ya esta habilitada la opción "Habilitar POP para los mensajes que se reciban a partir de ahora" en mi cuenta, pero no pasa nada, cambie la forma en que se muestran los mensajes para ver que ocurria, pero se queda igual: solo muestra el primer msginfo()
Code: Select all
MSGInfo( "Geting Internet email..." )
oInMail = TPop4():New( cIp,, "danyleon82@gmail.com", "tormenta82" ) // mail server IP
oInMail:bConnecting = { || MSGInfo( "Connecting to " + cIp ) }
oInMail:bConnected = { || MSGInfo( "Connected" ) }
oInMail:bDone = { || ReadEmails( oInMail ) }
Gracias..
Re: Programa que recibe e-mails?
Posted: Thu Oct 20, 2011 2:09 am
by jll-fwh
Buenas;
Tener en cuenta que dependiendo del tipo de cuentas, tanto enviar ( smtp ) como recibir correos ( pop, pop3 ), tiene asignados unos puertos, si el puerto no es correcto no podréis enviar ni recibir correos.
Los datos para cuenta GMAIL:
El servicio debe ser activado previamente en las opciones (Settings, Forwarding and POP, POP Download) y luego, configurar en el programa con los siguientes datos
Cuenta de Usuario: Tu email completo (ej:
yo@gmail.com)
Servidor de Correo Entrante: pop.gmail.com
Servidor de Correo Saliente: smtp.gmail.com (requiere autenticación)
Puerto POP3: 995 (requiere una conexión segura -SSL-)
Puerto SMTP: 465 (requiere una conexión segura -SSL-)
Para leer los correos, leer por el puerto 995.
Un saludo
JLL