Get email.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
zolysoftsolutions
Posts: 136
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Has thanked: 2 times
Contact:

Get email.

Post 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.
_______________________________
Open eyes for you!

User avatar
pctoledo
Posts: 123
Joined: Wed Aug 25, 2010 10:45 am
Location: Araçatuba - SP - Brazil
Has thanked: 3 times
Been thanked: 8 times
Contact:

Post 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
Regards/Saludos,

Toledo

Clipper On Line

User avatar
zolysoftsolutions
Posts: 136
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Has thanked: 2 times
Contact:

Post by zolysoftsolutions »

Thank you much PcToledo..
_______________________________
Open eyes for you!

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang »

Deat masters,
Thks but any suggestion to get the attachments ?

Tia

Best rgds
Chang
Just Hmg It !

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post 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
Just Hmg It !

User avatar
mol
Posts: 3434
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 277 times
Been thanked: 176 times
Contact:

Post 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;

User avatar
danielmaximiliano
Posts: 2375
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 460 times
Been thanked: 86 times
Contact:

Post by danielmaximiliano »

now I'm not at home, when you get to upload a working example servers yahoo, gmail and outlook.com (hotmail)
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
danielmaximiliano
Posts: 2375
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 460 times
Been thanked: 86 times
Contact:

Post 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 211 times
replace hmb.hbc to include these new libraries
hmg.3.3.1.hbc.rar
(743 Bytes) Downloaded 152 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 3383 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

Post by hmgchang »

Thks Masters,
I download and follow the instructions...
it compiled successfully... but get this message :
[img]

[/img]

TIA


best rgds,
Chang
Attachments
SslEay32.JPG
SslEay32.JPG (19.03 KiB) Viewed 3376 times
Just Hmg It !

User avatar
Rathinagiri
Posts: 5351
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 211 times
Been thanked: 232 times
Contact:

Post by Rathinagiri »

So, we got an emailing application ready. :) Super!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply