#include "Fivewin.ch"
FUNCTION MAIN()
? GETMAIL( "server", "userid", "password" )
RETURN NIL
STATIC FUNCTION GETMAIL( cServer, cUser, cPassword )
LOCAL lOk := .F.
LOCAL oCli
LOCAL aMail, aPar, cMsg, oAtt
LOCAL i
TRY
oCli = TIPClientPOP():New( "pop://" + STRTRAN( cUser, "@", "&at;" ) + ":" + cPassword + "@" + cServer )
IF EMPTY( oCli ); BREAK; ENDIF
oCli:oUrl:cUserid = cUser
IF !oCli:Open(); BREAK; ENDIF
aMail = oCli:RetrieveAll()
FOR i = 1 TO LEN( aMail ) - 1
aPar = aMail[ i ]:GetMultiParts()
IF LEN( aPar ) = 0
cMsg = "Data: " + aMail[ i ]:GetFieldPart( "Date" ) + CRLF +;
"Oggetto: " + aMail[ i ]:GetFieldPart( "Subject" ) + CRLF +;
"Mittente: " + aMail[ i ]:GetFieldPart( "From" ) + CRLF + CRLF +;
"Messaggio: " + CRLF + CRLF + aMail[ i ]:GetBody()
ELSE
cMsg = "Data: " + aMail[ i ]:GetFieldPart( "Date" ) + CRLF +;
"Oggetto: " + aMail[ i ]:GetFieldPart( "Subject" ) + CRLF +;
"Mittente: " + aMail[ i ]:GetFieldPart( "From" ) + CRLF + CRLF +;
"Messaggio: " + CRLF + CRLF + BODY( aPar )
ENDIF
WHILE ( oAtt := aMail[ i ]:NextAttachment() ) != NIL
IF !EMPTY( oAtt:GetFileName() )
cMsg += CRLF + "Allegato: " + oAtt:GetFileName()
// IF !oAtt:DetachFile(); BREAK; ENDIF
ENDIF
ENDDO
? cMsg
NEXT
lOk = .T.
CATCH
END
IF !EMPTY( oCli ); oCli:Close(); ENDIF
RETURN lOk
STATIC FUNCTION BODY( aPar )
LOCAL cMsg := ""
LOCAL i
FOR i = 1 TO LEN( aPar )
IF EMPTY( aPar[ i ]:GetFieldPart( "Content-Disposition" ) )
cMsg += aPar[ i ]:GetBody()
ENDIF
NEXT
RETURN ALLTRIM( cMsg )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 84 guests