FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour tGmail class
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tGmail class
Posted: Sun Jun 08, 2025 07:17 PM

I finally got this working. I went back to my Google email account and deleted the API keys. I added the new software ( updated Class ) and created a new API key. It finally worked.

Now I will take my existing email program and make the appropriate updates to allow this system to also work within the same usage of SMTP and IMAPI protocals that are already employed.

Thank you Lailton for the assistance.

I am now wondering, also, if we can get a FWH app authorized by Google. Since we make no money off of this addition to an existing program, is it free, or is Google expecting us to pay for some type of subscription. ( That's a non-starter for me ). I did try the authorize process and the initial response was that it did not meet Google's security requirements.

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
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Re: tGmail class
Posted: Mon Jun 09, 2025 11:23 AM

This is definitely the best solution for our systems in Harbour/xHb, so I would also like to be testing the new gMail class, how can I get it?

Regards.

FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tGmail class
Posted: Mon Jun 09, 2025 04:36 PM

The class is already in the latest release, and all of the files are in FWH/samples/gmail folder.

Lailton just sent me an upgraded class which is working. Perhaps he can note the fix here. The source is already included in the FWH/source folder. You can add that code to your program for now, and it will be fixed in the next set of libs released.

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
Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: tGmail class
Posted: Mon Jun 09, 2025 10:48 PM

You’re welcome! If you have any issues, feel free to let me know.

The change has already been applied to FWH and will be available for everyone in the next release.

I’m also planning to implement the one for Microsoft (Outlook/Office365).

I’ll let you know when it’s ready.

Regards,

Lailton Fernando Mariano
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tGmail class
Posted: Mon Jun 09, 2025 10:56 PM

My program creates emails to send to clients, and anything that has a print output ( invoices, messages, error logs, reports ) can be sent to anyone.

For years I was fine with SMTP. MAPI was a good alternative if it was available.

Now with this library, I have made it possible for my clients to also use gmail. It is working seamlessly.

I look forward to the one for Office 365 and will be happy to test it if you wish. Then, when it is working, I can also add it to my main program.

Thank you for the solution.

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
Posts: 38
Joined: Thu Aug 04, 2022 12:45 PM
Re: tGmail class
Posted: Tue Jun 10, 2025 07:17 PM

Hi, im using FWH25.04 b2, in dir samples/gmail date is 18/05, can you share updated version? can i use with ms365 (exchange) too? thanks

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tGmail class
Posted: Wed Jun 11, 2025 03:35 PM

What you see in the samples directory is sufficient. Lailton would need to help you with the updated class itself. I didn't look to see what he changed, but just used the code he emailed me.

As for Microsoft 365, that would be a different routine and class that is not yet provided. I believe he is working on it as time permits.

Tim

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
Posts: 670
Joined: Wed Oct 19, 2005 06:41 PM
Re: tGmail class
Posted: Wed Jun 11, 2025 06:19 PM

Lailton i'll Wait for 365 and of course aquire the version with that

many thanks

wilson

Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Posts: 38
Joined: Thu Aug 04, 2022 12:45 PM
Re: tGmail class
Posted: Wed Jun 11, 2025 06:55 PM

Hi TIM, Thank you.

regards.

Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: tGmail class
Posted: Wed Jun 11, 2025 10:56 PM
Great!

Soon we will have the TOffice365.
I will let you know when it be available. ;)
Regards,

Lailton Fernando Mariano
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Re: tGmail class
Posted: Fri Jun 13, 2025 01:20 PM
The follow code:
#include "FiveWin.ch"
function Main()
    LOCAL oGmail,hStore
    ? "Start..."
    hStore := readStore( hb_dirBase() + "gmail.json" )
    oGmail := TGmail():new()
    // USE Your ID and Secret Key. check README.md
    oGmail:setConfig( {;
        "client_id" => "xxxxxxxxxxxxxxxxx",;
        "client_secret" => "xxxxxxxxxxxxxxz",;
        "redirect_uri" => "http://localhost:2025/";
    } )
    if !empty( hStore[ "token" ] )
        oGmail:setToken( hStore[ "token" ] )
    endif
    ? "Connect..."
    onConnect( oGmail,hStore )
    ? "Send..."
    onSendMail( oGmail )
    ? "Disconnect..."
    onDisconnect( oGmail )
    saveStore( hb_dirBase() + "gmail.json", hStore )
RETURN( .T. )

function onConnect( oGmail,hStore )
    local cToken
    if !oGmail:isAuth()
        cToken := oGmail:auth()
        if !empty( cToken )
            hStore[ "token" ] := cToken
        else
            msgStop( "Authentication failed!" )
        endif
    endif
return nil

function onDisconnect( oGMail )
    local cProfile := hb_dirBase() + "profile_gmail.jpg"

    oGmail:revoke()
    if file( cProfile )
        ferase( cProfile )
    endif
return nil

function onSendMail( oGmail )
    if oGmail:send( "eroni_americo@yahoo.com.br", "Teste", "<b>Message from Gmail oAuth2</b>", .t., {} )
        msgInfo( "Mail sent!" )
    else
        msgStop( "Failed to send email. You may not have authorized the required permissions..." )
    endif
return nil

function readStore( cFile )
    local hStore
    if file( cFile )
        hb_jsonDecode( memoRead( cFile ), @hStore )
    endif
    if !hb_isHash( hStore )
        hStore := {;
            "token" => "";
        }
    endif
return hStore

function saveStore( cFile, hStore )
    hb_memoWrit( cFile, hb_jsonEncode( hStore ) )
return file( cFile )
Compiling in xHarbour131 BCC77, fails to run:
"Application cannot be started. 0x00000b .........."

Compiling in Harbour320 Visual Studio v17.14.5 , fails to run:
"Application cannot be started. 0x00000b .........."

The same problem.
Any ideas?

Thanks in advance.


Any ideas?
FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#
Posts: 231
Joined: Fri Jul 20, 2012 01:49 AM
Re: tGmail class
Posted: Fri Jun 13, 2025 06:43 PM

Hey there.

Does you have the Dlls ( libcurl.dll, freeimage32.dll/freeimage64.dll, zlib1.dll ) on the same directory than exe?

Regards,

Lailton Fernando Mariano
Posts: 114
Joined: Fri Jul 21, 2006 07:15 PM
Re: tGmail class
Posted: Fri Jun 13, 2025 08:44 PM

Yes. Samples folder of Fivewin. All Dlls are there.

FWH / xHarbour / BCC / MySql

Visual Studio / Harbour / DotNet Maui / C#

Continue the discussion