Connect before sending?

Hello; On other thread, you said me I have to call Connect before sending an email.

But even I have a token saved and even setting it before doing Connect, the authorization page is starting again, asking for authorization

GMail.Authentication.AccessToken := FToken;
GMail.Connect;

On the VCL version, I only need to TestTocken for sending, doing this:

  if not GMail.TestTokens then
    GMail.RefreshAccess;
  if not GMail.TestTokens then
    raise Exception ....
  if not GMail.SendMessage(GMail.Mails[0]) then
    raise Exception ...

So, is it absolutely necessary to do Connect for sending?

Thank you!

Hi,

If there is already a valid access token available its not required to call Connect.
However, the Connect call shouldn't trigger the authentication page when a valid access token is assigned.
Can you please make sure you don't have PersistTokens enabled? This would override the existing AccessToken value from the first line in your example when calling connect.

Right! was my mistake, very sorry.

BTW, in my project it is fine to load the browser for authorization process when we are doing account configuration, but not when we are sending e-mails. Which is the best way to cancel the authorization process? (In the VCL version I used TestTokens instead of Connect). Thank you!

Hello,
Very sorry but I have to come back to this thread. Working with TMS FNC, I am founding that GMail tokens saved yesterday are not working today. So I went to my TMS VCL version of the project, I saved new GMail tokens, then I tried to use them with the TMS FNC version and they are also not working (I mean, when I call Connect the browser is opened for autenthication). But if I try the same tokens again with TMS VCL version they are working fine.

Why is this?

Please note that tokens are not compatible between TMS FNC Cloud Pack and TMS VCL Cloud Pack.