POP Email Service / Reader

POP Email Service / Reader

Postby TimStone » Thu Jan 08, 2009 4:02 pm

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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: POP Email Service / Reader

Postby StefanHaupt » Thu Jan 08, 2009 8:05 pm

Tim,

here is a simple funktion to get email from a pop server. It does neither handle attachments nor html emails. It´s out of one of my unfinished projects. I hope it helps you to get started.

Code: Select all  Expand view
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)


kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 100 guests

cron