I use SMTP to send outgoing emails from my software. Now I'm thinking of doing a new capability and I'd like to retrieve emails ( POP ) and read them within my program.
Has anyone implemented this type of capability ? I'd love to see a sample.
METHOD GetMail () CLASS TEmail
LOCAL oPop
LOCAL aMsg := {}
LOCAL cPass := SPACE (20)
IF EMPTY (::cPass)
IF !::GetPass (@cPass)
RETURN (nil)
ENDIF
::SetPass (ALLTRIM (cPass))
ENDIF
::aMsgFiles := {} // Messagearray initialisieren
//oPop:=TPop():New( ::cPopServer, ::cLogin, ::cPass,,"Status.log")
oPop = TPop3():New( ::cPopServer,,; // mail server IP
::cLogin, ::cPass )
oPop:bConnecting := { || MsgRun ("Verbinde mit " + ::cPopServer,"Email abfragen")}
oPop:bConnected := { || MsgRun ("Verbunden ...","Email abfragen") }
oPop:bDone := { || aMsg := oPop:aMsg, ReadMails( aMsg ) }
oPop:GetMail()
//IF !oPop:lAllOk
// MsgInfo ("Fehler","Email abfragen")
//ENDIF
RETURN (nil)
//------------------------------------------------------------------
//
//
//------------------------------------------------------------------
Function ReadMails (aMsg)
LOCAL nMsg
LOCAL n
nMsg := LEN (aMsg) // Anzahl empfangener Nachrichten
IF nMsg > 0
FOR nMsg := 1 TO nMsg
// AADD (::aMsgFiles, oPop:aMsg[nMsg] ) // Dateinamen speichern
NEXT
ELSE
MsgInfo ("Keine neuen Nachrichten")
ENDIF
IF LEN (aMsg)>0
// ::MsgToArray () // Maildateien auslesen und in ::aInMail speichern
ENDIF
//IF ::lAutoSave
// ::MsgToDbf () // Nachrichten aus Array in DBF speichern
//ENDIF
RETURN (nil)
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 102 guests