Page 1 of 3

Get email.

Posted: Fri Jun 27, 2014 3:24 am
by zolysoftsolutions
Hi all.

Can I recive email trough a HMG application?
I know that can send email, but I have to recieve too..I need to store the name of the sender and the subject in some way.

Thank you.

Best regards,
Zoli B.

Re: Get email.

Posted: Fri Jun 27, 2014 8:59 pm
by pctoledo
Hi Zoli,

You can use the hbtip, look at a small example:

Code: Select all

********************************************
* Compilar: hbmk2 demo.prg -lhbtip
********************************************

PROCEDURE Main
LOCAL oPop, oPart, aParts, oTIpMail, aEmails, i, cFrom, cMsg, n_i
LOCAL cUser:="toledo@pctoledo.com.br"
LOCAL cSenha:="password"
LOCAL cServer:="pop.pctoledo.com.br"

CLS

oPop := TIpClientPop():new( "pop://"+strtran(cUser,"@","&at;")+":"+cSenha+"@"+cServer )

IF EMPTY( oPop )
 Alert("Erro ao criar objeto oPop")
 RETURN
ENDIF

oPop:oUrl:cUserid = cUser

oPop:nConnTimeout = -1

IF !oPop:Open()
  Alert("Erro na abertura da conta oPop")
  RETURN
ENDIF

aEMails := oPop:retrieveAll()
oPop:close()

nTot:=Len( aEMails )

// Show only 3 posts
If nTot>3
 nTot:=3
Endif
// To show all posts, delete these lines

FOR i:=1 TO nTot
  oTIpMail := aEmails[i]
  cFrom:=oTIpMail:getFieldPart( "From" )
  cSubject:=oTIpMail:getFieldPart( "Subject" )
  IF oTIpMail:isMultiPart()
    aParts := oTIpMail:getMultiParts()
    FOR EACH oPart IN aParts
      cMsg:=oPart:getBody()
    NEXT
  ELSE
    cMsg:=oTIpMail:getBody()
  ENDIF
  ? "From: ",cFrom, " - Subject: ",cSubject
  // Limit 500 characters
  ? subs(cMsg,1,500)
  ? ""
NEXT
RETURN

Re: Get email.

Posted: Sat Jun 28, 2014 4:18 am
by zolysoftsolutions
Thank you much PcToledo..

Re: Get email.

Posted: Sat Sep 13, 2014 4:33 am
by hmgchang
Deat masters,
Thks but any suggestion to get the attachments ?

Tia

Best rgds
Chang

Re: Get email.

Posted: Tue Sep 16, 2014 8:37 am
by hmgchang
Dear Mr. Toledo...
I tried your code with gmail and yahoo...
but unfortunately no luck...
Pls advise me on how to do it for gmail and yahoo...
( pop.gmail.com and pop.mail.yahoo.com) ?

TIA

best rgds,
Chang

Re: Get email.

Posted: Tue Sep 16, 2014 10:53 am
by mol
I think, You've got problem with user login containing "@" character.
Did you tried this solution:
viewtopic.php?f=5&t=2573" onclick="window.open(this.href);return false;

Re: Get email.

Posted: Tue Sep 16, 2014 8:00 pm
by danielmaximiliano
now I'm not at home, when you get to upload a working example servers yahoo, gmail and outlook.com (hotmail)

Re: Get email.

Posted: Wed Sep 17, 2014 1:53 am
by danielmaximiliano
hmgchang wrote:I tried your code with gmail and yahoo...
but unfortunately no luck...
Hi Chang :

Yahoo, Gmail and Hotmail and other services like email generalmentes use the HTTPs protocol //, POPs: // and SMTPs: // for secure connections.
read http://en.wikipedia.org/wiki/Transport_Layer_Security

it needs also the library HbSSL with HbTip together to try to communicate your application with the mail server.
this applies safety and that no other person sees your username and password and other data sent through the unsafe area such as the Internet.

unzip the libraries in their respective folders within your installation HMG.3.3.1 :
hmg.3.3.1.rar
Lib and lib64 folder
(2.44 MiB) Downloaded 271 times
replace hmb.hbc to include these new libraries
hmg.3.3.1.hbc.rar
(743 Bytes) Downloaded 207 times
and rebuild the libraries using buildalllib.bat and buildalllib64.bat

add these lines to your application

Code: Select all

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

#require "hbtip"
#require "hbssl"

REQUEST __HBEXTERN__HBSSL__
Function main
...
Return
2014-09-16 22_51_24-HBTIP _ HBSSL incoming outgoing eMail.jpg
2014-09-16 22_51_24-HBTIP _ HBSSL incoming outgoing eMail.jpg (92.22 KiB) Viewed 4301 times

Re: Get email.

Posted: Wed Sep 17, 2014 3:20 am
by hmgchang
Thks Masters,
I download and follow the instructions...
it compiled successfully... but get this message :
[img]

[/img]

TIA


best rgds,
Chang

Re: Get email.

Posted: Wed Sep 17, 2014 4:02 am
by Rathinagiri
So, we got an emailing application ready. :) Super!