tGmail class

User avatar
TimStone
Posts: 3031
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: tGmail class

Post 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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
[email protected]
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
Eroni
Posts: 114
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Re: tGmail class

Post 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.
FWH / xHarbour / BCC / MySql
Visual Studio / Harbour / DotNet Maui / C#
User avatar
TimStone
Posts: 3031
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: tGmail class

Post 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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
[email protected]
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
Lailton
Posts: 231
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Contact:

Re: tGmail class

Post 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.
Regards,
Lailton Fernando Mariano
User avatar
TimStone
Posts: 3031
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: tGmail class

Post 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.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
[email protected]
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
NWKL
Posts: 39
Joined: Thu Aug 04, 2022 12:45 pm

Re: tGmail class

Post 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
User avatar
TimStone
Posts: 3031
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: tGmail class

Post 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
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
[email protected]
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
wilsongamboa
Posts: 672
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Re: tGmail class

Post by wilsongamboa »

Lailton i'll Wait for 365 and of course aquire the version with that
many thanks
wilson
Wilson 'W' Gamboa A
[email protected]
User avatar
NWKL
Posts: 39
Joined: Thu Aug 04, 2022 12:45 pm

Re: tGmail class

Post by NWKL »

Hi TIM, Thank you.
regards.
User avatar
Lailton
Posts: 231
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Contact:

Re: tGmail class

Post by Lailton »

Great!

Soon we will have the TOffice365.
I will let you know when it be available. ;)
Regards,
Lailton Fernando Mariano
User avatar
Eroni
Posts: 114
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Re: tGmail class

Post 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?
FWH / xHarbour / BCC / MySql
Visual Studio / Harbour / DotNet Maui / C#
User avatar
Lailton
Posts: 231
Joined: Fri Jul 20, 2012 1:49 am
Location: Brazil
Contact:

Re: tGmail class

Post by Lailton »

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
User avatar
Eroni
Posts: 114
Joined: Fri Jul 21, 2006 7:15 pm
Location: Criciuma/SC Brazil
Contact:

Re: tGmail class

Post by Eroni »

Yes. Samples folder of Fivewin. All Dlls are there.
FWH / xHarbour / BCC / MySql
Visual Studio / Harbour / DotNet Maui / C#
Post Reply