Using gmail

Using gmail

Postby Antonio Linares » Tue May 14, 2013 9:36 am

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oMsg  := CreateObject( "CDO.Message" )
   local oConf := CreateObject( "CDO.Configuration" )
   local cSchema := "http://schemas.microsoft.com/cdo/configuration/"
   
   oConf:Fields[ cSchema + "sendusing" ] = 2
   oConf:Fields[ cSchema + "smtpserver" ] = "smtp.gmail.com"
   oConf:Fields[ cSchema + "smtpserverport" ] = 465
   oConf:Fields[ cSchema + "smtpauthenticate" ] = 1
   oConf:Fields[ cSchema + "sendusername" ] = "alinares@fivetechsoft.com"
   oConf:Fields[ cSchema + "sendpassword" ] = "yourpassword"
   oConf:Fields[ cSchema + "smtpusessl" ] = 1
   oConf:Fields:Update()
   
   oMsg:To = "antonio.fivetech@gmail.com"
   oMsg:From ="Antonio <alinares@fivetechsoft.com>"
   oMsg:Subject = "Test send with gmail account"
   oMsg:HTMLBody = "it works"
   oMsg:Sender = "Antonio"
   oMsg:Organization = "FiveTech"
   oMsg:ReplyTo = "alinares@fivetechsoft.com"
   oMsg:Configuration = oConf
   
   oMsg:Send()
   MsgInfo( "done" )
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Re: Using gmail

Postby Antonio Linares » Tue May 14, 2013 10:56 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby MGA » Tue May 14, 2013 11:07 am

Thanks
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1249
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Using gmail

Postby Antonio Linares » Tue May 14, 2013 11:32 am

Working! :-)

Code: Select all  Expand view
#include "FiveWin.ch"
#include "c:\harbour\contrib\hbcurl\hbcurl.ch"

#define HB_CURLOPT_RETURNTRANSFER 500

#define OUTFILE  "gmail.xml"

function Main()

   local hCurl, aMatch, cPage, cAction

   curl_global_init()

   if ! Empty( hCurl := curl_easy_init() )
      curl_easy_setopt( hCurl, HB_CURLOPT_URL, "https://mail.google.com/mail/feed/atom" )
      curl_easy_setopt( hCurl, HB_CURLOPT_FOLLOWLOCATION, 1 )
      curl_easy_setopt( hCurl, HB_CURLOPT_RETURNTRANSFER, 1 )
      curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
      curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "antonio.fivetech" + ":" + "yourpassword" )
      curl_easy_setopt( hCurl, HB_CURLOPT_HTTPAUTH, HB_CURLAUTH_BASIC )
      curl_easy_setopt( hCurl, HB_CURLOPT_DL_FILE_SETUP, OUTFILE )
      curl_easy_perform( hCurl )
      curl_easy_reset( hCurl )
   endif

   curl_global_cleanup()

   if File( OUTFILE )
      ParseXML()
   endif  

return nil  

function ParseXML()
   
   local hFile    := FOpen( OUTFILE )
   Local oXmlDoc  := TXmlDocument():New( hFile )
   Local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
   local aItems   := {}, oEmail

   while .T.
      oTagActual = oXmlIter:Next()
      If oTagActual != nil
         if Upper( AllTrim( oTagActual:cName ) ) == "TITLE"
            if oEmail != nil
               AAdd( aItems, { oEmail:cDate, oEmail:cAuthorName, oEmail:cTitle } )
            endif
            oEmail = TEmail():New()  
            oEmail:cTitle = oTagActual:cData
         endif  

         if Upper( AllTrim( oTagActual:cName ) ) == "ISSUED"
            oEmail:cDate = oTagActual:cData
         endif  

         if Upper( AllTrim( oTagActual:cName ) ) == "AUTHOR"
            oTagActual = oXmlIter:Next()
            oEmail:cAuthorName = oTagActual:cData
            oTagActual = oXmlIter:Next()
            oEmail:cAuthorEmail = oTagActual:cData
         endif  

         // HEval( oTagActual:aAttributes, { | cKey, cValue | MsgInfo( cKey, cValue ) } )
      Else
         Exit
      Endif
   End

   FClose( hFile )

   XBROWSER aItems ;
      SETUP ( oBrw:aCols[ 1 ]:cHeader := "Date",;
              oBrw:aCols[ 2 ]:cHeader := "From",;
              oBrw:aCols[ 3 ]:cHeader := "Title" )

return nil

CLASS TEmail

   DATA  cTitle
   DATA  cDate
   DATA  cAuthorName
   DATA  cAuthorEmail
   
ENDCLASS  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Antonio Linares » Tue May 14, 2013 11:41 am

screenshot:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Massimo Linossi » Wed May 15, 2013 7:25 am

Hi Antonio.
Is it possible to have the curl.lib for the xharbour commercial ?
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using gmail

Postby Antonio Linares » Wed May 15, 2013 8:27 am

Massimo,

Here you have it:
https://code.google.com/p/harbour-and-xharbour-builds/downloads/detail?name=hbcurl.lib

I have not tested it yet with xHarbour, so your feedback is really welcome :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Massimo Linossi » Wed May 15, 2013 9:13 am

Hi Antonio.
These are the errors I receive.


Type: C >>>xhb.exe -o"c\mail.c" -m -n -p -q -gc0 -I"C:\fwh\include" -I"C:\xHB\include" -I"C:\xHB\include\w32" "mail.prg"<<<

xHarbour Compiler build 1.0.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
Generating object output to 'c\mail.obj'...

Type: C >>>xlink.exe -NOEXPOBJ -MAP -FORCE:MULTIPLE -NOIMPLIB -subsystem:windows -UNMANGLE -LIBPATH:"C:\xHB\lib" -LIBPATH:"C:\xHB\c_lib" -LIBPATH:"C:\xHB\c_lib\win" -LIBPATH:"C:\fwh\lib" "c\mail.obj" "hbcurl.lib" "FiveHCM.lib" "FiveHMX.lib" "OptG.lib" "xhb.lib" "dbf.lib" "ntx.lib" "cdx.lib" "rmdbfcdx.lib" "ct3.lib" crt.lib kernel32.lib user32.lib winspool.lib ole32.lib oleaut32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib ws2_32.lib wininet.lib advapi32.lib shlwapi.lib msimg32.lib mpr.lib comctl32.lib comdlg32.lib gdi32.lib shell32.lib winmm.lib lz32.lib Netapi32.lib -out:"test.exe"<<<

xLINK: error: Unresolved external symbol '__imp__curl_global_init_mem'.
xLINK: error: Unresolved external symbol '__imp__curl_global_cleanup'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_duphandle'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_init'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_setopt'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_cleanup'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_reset'.
xLINK: error: Unresolved external symbol '__imp__curl_formfree'.
xLINK: error: Unresolved external symbol '__imp__curl_slist_free_all'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_pause'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_perform'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_send'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_recv'.
xLINK: error: Unresolved external symbol '__imp__curl_formadd'.
xLINK: error: Unresolved external symbol '__imp__curl_slist_append'.
xLINK: error: Unresolved external symbol '_dv_memcpy'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_getinfo'.
xLINK: error: Unresolved external symbol '_hb_arraySetC'.
xLINK: error: Unresolved external symbol '_hb_itemReturnRelease'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_escape'.
xLINK: error: Unresolved external symbol '__imp__curl_free'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_unescape'.
xLINK: error: Unresolved external symbol '__imp__curl_version'.
xLINK: error: Unresolved external symbol '__imp__curl_version_info'.
xLINK: error: Unresolved external symbol '_hb_arraySetNI'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_strerror'.
xLINK: error: Unresolved external symbol '__imp__curl_getdate'.
xLINK: error: Unresolved external symbol '__imp__curl_escape'.
xLINK: error: Unresolved external symbol '__imp__curl_unescape'.
xLINK: fatal error: 29 unresolved external(s).

Type: C >>>Couldn't build: test.exe<<<
Type: C >>>TMAKEPROJECT<<<
Type: C >>>TMAKEPROJECT:REFRESH<<<
Type: N >>> 1322<<<
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using gmail

Postby Antonio Linares » Wed May 15, 2013 1:37 pm

Massimo,

You have to link libcurl.lib that you can download from here:

http://curl.haxx.se/download.html

I think the version you need should be in this version:
http://curl.haxx.se/gknw.net/7.30.0/dist-w64/curl-7.30.0-devel-mingw64.7z
and the name is lib\Release\curllib_static.lib in this package

Please try it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Antonio Linares » Wed May 15, 2013 2:25 pm

Sending an email with gmail:

viewtopic.php?p=111825#p111825
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Massimo Linossi » Wed May 15, 2013 2:55 pm

Hi Antonio.
In your link file there was no .lib file inside.
I've tried to download a lib from win32 development.
Compiling I receive now there errors.
Thanks again.

Type: C >>>xlink.exe -NOEXPOBJ -MAP -FORCE:MULTIPLE -NOIMPLIB -subsystem:windows -UNMANGLE -LIBPATH:"C:\xHB\lib" -LIBPATH:"C:\xHB\c_lib" -LIBPATH:"C:\xHB\c_lib\win" -LIBPATH:"C:\fwh\lib" "c\mail.obj" "hbcurl.lib" "libcurl.lib" "FiveHCM.lib" "FiveHMX.lib" "OptG.lib" "xhb.lib" "dbf.lib" "ntx.lib" "cdx.lib" "rmdbfcdx.lib" "ct3.lib" crt.lib kernel32.lib user32.lib winspool.lib ole32.lib oleaut32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib ws2_32.lib wininet.lib advapi32.lib shlwapi.lib msimg32.lib mpr.lib comctl32.lib comdlg32.lib gdi32.lib shell32.lib winmm.lib lz32.lib Netapi32.lib -out:"test.exe"<<<

xLINK: error: Unresolved external symbol '__imp__curl_easy_send'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_recv'.
xLINK: error: Unresolved external symbol '_dv_memcpy'.
xLINK: error: Unresolved external symbol '_hb_arraySetC'.
xLINK: error: Unresolved external symbol '_hb_itemReturnRelease'.
xLINK: error: Unresolved external symbol '_hb_arraySetNI'.
xLINK: fatal error: 6 unresolved external(s).

Type: C >>>Couldn't build: test.exe<<<
Type: C >>>TMAKEPROJECT<<<
Type: C >>>TMAKEPROJECT:REFRESH<<<
Type: N >>> 1322<<<
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using gmail

Postby Antonio Linares » Wed May 15, 2013 3:36 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42060
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Using gmail

Postby Massimo Linossi » Wed May 15, 2013 4:20 pm

Hello Antonio.
I've downloaded your file, and linked the cur lib_static from the lib<release folder.
And there are other errors. :cry:


Type: C >>>xlink.exe -NOEXPOBJ -MAP -FORCE:MULTIPLE -NOIMPLIB -subsystem:windows -UNMANGLE -LIBPATH:"C:\xHB\lib" -LIBPATH:"C:\xHB\c_lib" -LIBPATH:"C:\xHB\c_lib\win" -LIBPATH:"C:\fwh\lib" "c\mail.obj" "hbcurl.lib" "curllib_static.lib" "FiveHCM.lib" "FiveHMX.lib" "OptG.lib" "xhb.lib" "dbf.lib" "ntx.lib" "cdx.lib" "rmdbfcdx.lib" "ct3.lib" crt.lib kernel32.lib user32.lib winspool.lib ole32.lib oleaut32.lib odbc32.lib odbccp32.lib uuid.lib wsock32.lib ws2_32.lib wininet.lib advapi32.lib shlwapi.lib msimg32.lib mpr.lib comctl32.lib comdlg32.lib gdi32.lib shell32.lib winmm.lib lz32.lib Netapi32.lib -out:"test.exe"<<<

xLINK: error: Unresolved external symbol '__imp__curl_global_init_mem'.
xLINK: error: Unresolved external symbol '__imp__curl_global_cleanup'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_duphandle'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_init'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_setopt'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_cleanup'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_reset'.
xLINK: error: Unresolved external symbol '__imp__curl_formfree'.
xLINK: error: Unresolved external symbol '__imp__curl_slist_free_all'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_pause'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_perform'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_send'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_recv'.
xLINK: error: Unresolved external symbol '__imp__curl_formadd'.
xLINK: error: Unresolved external symbol '__imp__curl_slist_append'.
xLINK: error: Unresolved external symbol '_dv_memcpy'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_getinfo'.
xLINK: error: Unresolved external symbol '_hb_arraySetC'.
xLINK: error: Unresolved external symbol '_hb_itemReturnRelease'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_escape'.
xLINK: error: Unresolved external symbol '__imp__curl_free'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_unescape'.
xLINK: error: Unresolved external symbol '__imp__curl_version'.
xLINK: error: Unresolved external symbol '__imp__curl_version_info'.
xLINK: error: Unresolved external symbol '_hb_arraySetNI'.
xLINK: error: Unresolved external symbol '__imp__curl_easy_strerror'.
xLINK: error: Unresolved external symbol '__imp__curl_getdate'.
xLINK: error: Unresolved external symbol '__imp__curl_escape'.
xLINK: error: Unresolved external symbol '__imp__curl_unescape'.
xLINK: fatal error: 29 unresolved external(s).

Type: C >>>Couldn't build: test.exe<<<
Type: C >>>TMAKEPROJECT<<<
Type: C >>>TMAKEPROJECT:REFRESH<<<
Type: N >>> 1322<<<
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Using gmail

Postby Massimo Linossi » Wed May 15, 2013 6:34 pm

Hello Antonio.
It is possible to use the first code of this topic reading all emails from Gmail server and to save
the attachments ?
TIA
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests