Moderator: Enrico Maria Giordano
STATIC FUNCTION GETMAIL( cServer, cUser, cPassword )
LOCAL lOk := .F.
LOCAL oCli
LOCAL aMail, aPar, cMsg, oAtt
LOCAL i, j
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
cMsg = "Data: " + aMail[ i ]:GetFieldPart( "Date" ) + CRLF +;
"Oggetto: " + aMail[ i ]:GetFieldPart( "Subject" ) + CRLF +;
"Mittente: " + aMail[ i ]:GetFieldPart( "From" ) + CRLF + CRLF
aPar = aMail[ i ]:GetMultiParts()
IF LEN( aPar ) = 0
cMsg += "Messaggio: " + CRLF + CRLF + aMail[ i ]:GetBody()
ELSE
cMsg += "Messaggio: " + CRLF + CRLF + BODY( aPar )
ENDIF
WHILE ( oAtt := aMail[ i ]:NextAttachment() ) != NIL
IF !EMPTY( oAtt:GetFileName() )
cMsg += CRLF + "Allegato: " + oAtt:GetFileName()
// IF !oAtt:DetachFile() THEN BREAK
ENDIF
ENDDO
FOR j = 1 TO LEN( aPar )
WHILE ( oAtt := aPar[ j ]:NextAttachment() ) != NIL
IF !EMPTY( oAtt:GetFileName() )
cMsg += CRLF + "Allegato: " + oAtt:GetFileName()
// IF !oAtt:DetachFile(); BREAK; ENDIF
ENDIF
ENDDO
NEXT
? 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 )
oMail = oCli:Retrieve( n )
Return to All products support
Users browsing this forum: No registered users and 16 guests