In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

TMapi: Logon() fails

Xailer professional forum in English
Responder
Timm
Mensajes: 136
Registrado: Lun Jun 21, 2010 11:01 am

TMapi: Logon() fails

Mensaje por Timm »

Hi!

With the example from \Samples\Internet\SimpleMAPI I cannot send mails via TMapi under Windows 11, neither with Outlook 365 nor with Thunderbird.
Logon() is not executed successfully.

Does anyone have any advice?

Best regards, Timm
Timm
Mensajes: 136
Registrado: Lun Jun 21, 2010 11:01 am

Re: TMapi: Logon() fails

Mensaje por Timm »

Hi!

Can anyone confirm the problem or is it just me?

Best regards, Timm
Pedro Gil
Mensajes: 115
Registrado: Lun Ene 15, 2007 7:46 pm

Re: TMapi: Logon() fails

Mensaje por Pedro Gil »

Hi Timm,

You could check the nLastError PROPERTY to see the reason why MAPILogon fails.

Kind regards.
Timm
Mensajes: 136
Registrado: Lun Jun 21, 2010 11:01 am

Re: TMapi: Logon() fails

Mensaje por Timm »

Hi Pedro,

the error code is -2147467259 but I can't find any information about it.

Best regards, Timm
Pedro Gil
Mensajes: 115
Registrado: Lun Ene 15, 2007 7:46 pm

Re: TMapi: Logon() fails

Mensaje por Pedro Gil »

Hi Timm,

If I'm not wrong such an error corresponds to MAPI_E_CALL_FAILED (0x80004005) and it seems that it's a generic error and difficult to fix it without more information.

Anyway, I stopped using that class a long time ago. I'm now using GmailSend and it works fine with Win10 and Win11. True, it's not easy to start using it, but the following comments can be useful to you:

TGmailSend

NOTE: This class only works in multi-threaded mode. To do this, you must uncheck the hbvm library in the Properties of your project and link the hbvmmt library.

The first step to be able to send is to create a Google API Console Project by accessing the following Internet address:
https://console.cloud.google.com/projec ... is/library. From there you will need to create a new project, and once created, select the menu option (in the sidebar) API and Services > OAuth Consent Screen. Fill in the information requested and complete all the steps.
Next, select the API & Services > Credentials menu option and click CREATE CREDENTIALS for OAuth Client ID. When prompted for Application Type, indicate Desktop App and fill in the Name field.

For each OAuth Client ID Google will provide you with two very important pieces of information which are the ClientID and the Secret ID. These two values must be entered in the cClientID and cSecretID properties of the TGmailSend control. However, an additional piece of information is needed which is the Token, which we will talk about later.
The next step is to enable the use of Gmail API for the newly created project. To do this, select the API & Services > Panel menu option and click ENABLE API & SERVICES. Then select Gmail API and click ENABLE.

The first time you try to send a mail message through TGmailSend, the program will show the user the classic Gmail login web page asking for the user's login credentials and indicating that a certain service (your project) wants to send an email on your behalf. If the user enters his credentials correctly and also authorizes the project to send the mail on his behalf, the mail should be sent without any problems. (You may get the message that a connection could not be established with the server at 127.0.0.1.)

Once the mail is sent, a token will be generated, which is stored in the cToken property of the TGmailSend control. If, before destroying the control, you save this token and assign it to the cToken property before sending an email again, the user will not be asked for his credentials again. (See the example \samples\gmail.) Note that the tokens may expire and therefore an error may occur in the sending, circumstance that you will have to check to obtain a new token.

Warm regards.
Timm
Mensajes: 136
Registrado: Lun Jun 21, 2010 11:01 am

Re: TMapi: Logon() fails

Mensaje por Timm »

Hi Pedro,

many thanks for the informations!

Best regards, Timm.
Responder