Page 2 of 2

Re: tGmail class

Posted: Sun Jun 08, 2025 7:17 pm
by TimStone
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.

Re: tGmail class

Posted: Mon Jun 09, 2025 11:23 am
by Eroni
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.

Re: tGmail class

Posted: Mon Jun 09, 2025 4:36 pm
by TimStone
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.

Re: tGmail class

Posted: Mon Jun 09, 2025 10:48 pm
by Lailton
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.

Re: tGmail class

Posted: Mon Jun 09, 2025 10:56 pm
by TimStone
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.

Re: tGmail class

Posted: Tue Jun 10, 2025 7:17 pm
by NWKL
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

Re: tGmail class

Posted: Wed Jun 11, 2025 3:35 pm
by TimStone
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

Re: tGmail class

Posted: Wed Jun 11, 2025 6:19 pm
by wilsongamboa
Lailton i'll Wait for 365 and of course aquire the version with that
many thanks
wilson

Re: tGmail class

Posted: Wed Jun 11, 2025 6:55 pm
by NWKL
Hi TIM, Thank you.
regards.

Re: tGmail class

Posted: Wed Jun 11, 2025 10:56 pm
by Lailton
Great!

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

Re: tGmail class

Posted: Fri Jun 13, 2025 1:20 pm
by Eroni
The follow code:

Code: Select all | Expand

#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( "[email protected]", "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?

Re: tGmail class

Posted: Fri Jun 13, 2025 6:43 pm
by Lailton
Hey there.

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

Re: tGmail class

Posted: Fri Jun 13, 2025 8:44 pm
by Eroni
Yes. Samples folder of Fivewin. All Dlls are there.