Page 2 of 3

Re: Get email.

Posted: Wed Sep 17, 2014 4:19 am
by hmgchang
This is my ssw :

Code: Select all

#include <hmg.ch>
#include 'hfcl.ch'
#include "hbclass.ch"
#include "simpleio.ch"

#require "hbtip"
#require "hbssl"

REQUEST __HBEXTERN__HBSSL__

Function Main

        Load Window Main
        Main.Center
        Main.Activate

Return

FUNCTION btnGetMail_Action()
  // The example outlines the steps required for retrieving all
  // eMails from a POP mail server and how to decompose
  // incoming mail messages.

  LOCAL oPop, oPart, aParts, oTIpMail, aEmails, i
  
  cUser      := "hmgchang@gmail.com"
  cPassword  := "hmg123456"
  cPopServer := "pop.gmail.com" && "imap.googlemail.com" && 
  cUser      := STRTRAN( cUser, "@", "&at;")
  
  cTUrl := "pop://" + cUser + ":" + cPassword + "@" + cPopServer
  oUrl := TUrl():New( cTUrl)
  
  IF oUrl == NIL
    msgDebug( "Error : " + cTUrl)
    RETURN NIL
  ENDIF  
  
  oPop := TIpClientPop():new( oUrl, .F.)
  
  IF oPop == NIL
    msgDebug( "oPop := TIpClientPop():new( oUrl, .F.)")
    RETURN NIL
  ENDIF  
  
  cUser := STRTRAN( cUser, "&at;", "@")
  oPop:oUrl:cUserId := cUser
  
  oPop:nConnTimeout := -1

  *- oPop := TIpClientPop():new( "pop://mailaccount:password@pop.server.com" )
  *- oPop := TIpClientPop():new( "pop://" + cMailAccount + ":" + cPassword + "@" + cPopServer )

  IF .NOT. oPop:open()
     msgDebug( "Connection error:", oPop:lastErrorMessage(), "oPop:open()")
     QUIT
  ELSE
     aEMails := oPop:retrieveAll()
     oPop:close()
  ENDIF

  FOR i:=1 TO Len( aEMails )
     oTIpMail := aEmails[i]
     msgDebug( "From : ", oTIpMail:getFieldPart( "From" ))
     msgDebug( "Subject : ", oTIpMail:getFieldPart( "Subject" ))

     IF oTIpMail:isMultiPart()
        // Retrieve all parts of a multipart message
        aParts := oTIpMail:getMultiParts()

        FOR EACH oPart IN aParts
           IF .NOT. Empty( oPart:getFileName() )
              // This is a file attachment. Store it in the TMP folder.
              IF oPart:detachFile( "C:\tmp\" )
                 msgDebug( "Attach file :", "File written: C:\tmp\" + oPart:getFileName())
              ENDIF
           ELSE
              msgDebug( "GetBody :", oPart:getBody())
           ENDIF
        NEXT
     ELSE
        // simple mail message
        msgDebug( "Simple GetBody : ", oTIpMail:getBody())
     ENDIF
  NEXT
  RETURN NIL
  
I also download and installed the vcredist_x86.exe and Win32OpenSSL_Light-1_0_1i.exe.
But i got this message :

Re: Get email.

Posted: Wed Sep 17, 2014 5:50 pm
by Javier Tovar
Hola DanielMaximiliano,

El primer archivo adjunto no subio?, por que no selecciona nada para bajar.

Saludos

Re: Get email.

Posted: Wed Sep 17, 2014 10:48 pm
by danielmaximiliano
Hola Chang... This is my ssw
message.jpg
message.jpg (21.22 KiB) Viewed 3764 times
InOutEmail.rar
(1.92 KiB) Downloaded 260 times

Re: Get email.

Posted: Wed Sep 17, 2014 11:01 pm
by Javier Tovar
Disculpa DanielMaximiliano, es que al traducir la pagina al espaƱol, ya no sale tu primer archivo que subiste y mostrando la pagina original SI.

No me di cuenta hasta ahorita.

Saludos

Re: Get email.

Posted: Fri Sep 19, 2014 4:30 am
by hmgchang
Thank you very much Master Daniel,
i will download and meditate on it...

best regards,
Chang

Re: Get email.

Posted: Fri Sep 19, 2014 8:37 am
by hmgchang
Dear Daniel,

After filling in the user and password...
i tried to run your ssw....
this is what i got..
Connection Info
Connection Info
ConnectionInfo.JPG (14.36 KiB) Viewed 3714 times
and this is the ssw...
ChangGetMail.zip
(2.33 KiB) Downloaded 242 times
Pls advise and TIA

best rgds,
Chang

Re: Get email.

Posted: Fri Sep 19, 2014 8:38 am
by hmgchang
Dear master,

FYI,...
i can successfully login the gmail account by my browser...

Re: Get email.

Posted: Fri Sep 19, 2014 6:29 pm
by danielmaximiliano
hmgchang wrote:Dear Daniel,

After filling in the user and password...
i tried to run your ssw....
this is what i got..
need not indicate @gmail or @gmail.com this server

Code: Select all

  cUser          := "hmgchang" 
  cPassword      := "hmg123456"

Re: Get email.

Posted: Fri Sep 19, 2014 9:44 pm
by hmgchang
Dear Daniel....
I tried and it works...
Thank you very much....
and sorry for causing you troubles...

best rgds,
Chang

Re: Get email.

Posted: Sat Sep 20, 2014 1:29 am
by danielmaximiliano
hmgchang wrote:Dear Daniel....
I tried and it works...
Thank you very much....
and sorry for causing you troubles...

best rgds,
Chang

are pleased to help Chang