I try to send an email with TTMSFNCCloudMicrosoftOutlookMail; this is the procedure, but it seems nothing happen, and any message was sent. Is it a way to know what is the problem and/or the results?
MS.Authentication.ClientID := MAppkey;
MS.Authentication.Secret := MAppSecret;
MS.Authentication.CallBackURL := 'http://localhost:8888';
MS.Mails.Clear;
MS.Mails.Add;
MS.Mails[0].RecipientEmails.Text := 'myaddres@yahoo.com';
MS.Mails[0].Subject := 'Primera prueba MS';
MS.Mails[0].MailType := TTMSFNCCloudMicrosoftOutlookMailType.mtPlainText;
MS.Mails[0].Body := 'Este es el texto de la prueba MS';
MS.SendMessage(MS.Mails[0]);
MS.Mails.Clear;
Please note that you'll first have to call "Connect" to authenticate with the service. Once the OnConnected event is triggered you can begin sending emails.
After using "SendMessage" the OnSendMessage event is triggered. The event parameters contain the result of the request:
ARequestResult.Success: True if the request was successful, otherwise false
ARequestResult.ResultString: Contains the error data if an error occurs
I already connected to the service and I can see my application authorized, but when I did that, any of the two events for saving tokens are fired, so my app is not saving any token. Because of this, sendingd a mail is resulting in "InvalidAuthenticationToken".
Do you know why I am OnAuthenticated are not fired? (I did the same approach for the GMail component and it works very well).
Bart;
First of all: thank you for your great support. Now, as far I can see, me application is already registered with all the steps I see in your help document. When I do "connect", my application does the process of and it receives a "success" in the browser. And then, if I see the list of conected applications, the application appears listed, and this are the privileges:
Can you please provide the full ARequestResult.ResultString value for requests that are not successfully executed or a full log file so I can further investigate this?
If possible, please also provide screenshots of your authentication settings both in the Microsoft Azure console and in your Delphi application.
I think the problem is when I connect the first time, as I never get fired the OnAuthenticated and/or the OnConnected events. When I do Connect, the log file is filled with this:
20221027T091315: Executing request [TEST TOKENS] with url: [https://graph.microsoft.com/v1.0/me]
20221027T091316: Response code from request [TEST TOKENS] is 401
20221027T091325: Executing request [RETRIEVE ACCESS TOKEN] with url: [Sign in to your account]
20221027T091326: Response code from request [RETRIEVE ACCESS TOKEN] is 400
On the same time I am getting this on the browser:
I already sent you yesterday the screen in where you can see my application is connected to the user account.
The 400 response code is an error, which means there was a problem with retrieving the access token.
It's not clear from the log what is causing the problem.
Can you please check if the OnAccessDenied event is triggered and if so what the value of ARequestResult.Resultstring is?
Can you please provide screenshots of your authentication settings both in the Microsoft Azure console and in your Delphi application?
Thank you Bart. I think these are the images you are asking me for. The last one is the ARequestResult.Resultstring when OnAccessDenied event is triggered. Please note that Azure is accepting my, and then I can see the application connected to the platform.
Thanks Daniel, these are indeed the requested screenshots.
Can you please make sure to select "Web" (or the equivalent in your language) instead of "Desktop and mobile application" (or the equivalent in your language) as the application Platform?
Even if you are creating a desktop and/or mobile application you should still select "Web" to make the authentication in TMS FNC Cloud Pack function correctly.