Jump to content
J23

Delphi - send mail from Office 365 with EWS protocol

Recommended Posts

Sorry, I don't understand, there are no spaces in

https://graph.microsoft.com/Mail.Send

Now I only use the single one, and this Scope is accepted, in the app with EASendMail component.

All additional characters are placed by the OverbyteIcsHttpRestTst application.

 

J234

Share this post


Link to post

These are the pertinent arguments from my successful login this morning:

 

&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fmicrosoft%2F&state=ICS-232524578&scope=offline_access%20https%3A%2F%2Foutlook.office.com%2FSMTP.Send%20https%3A%2F%2Foutlook.office.com%2FPOP.AccessAsUser.All&prompt=select_account&access_type=offline

 

You could try removing the URL and just use SMTP.Send.

 

Angus

 

Share this post


Link to post

Hello Angus, I am very grateful for your time.

I tried to run the program on another computer, I removed the entire package and reinstalled. Nothing has changed.

There was only one problem during the installation: I had to manually add the path to the file OverbyteIcsSuperXMLParser.pas

I'd like to ask a few more questions:

- the program didn't ask for certificates but maybe I should create some certificates?

- are the settings visible in the REST Settings attachment sent yesterday are correct?

- maybe unlucky compilation in Delphi2010 causes some unusual problems?

- Maybe change the port to something other than 8080?

- Is there a compiled (exe) version of this program available somewhere? I know it's dangerous, but I'm determined to try all the options 😉

- I'm signing in with a trial Microsoft 365 work account - Microsoft 365 Business Basic - it doesn't matter?

 

J23

Share this post


Link to post

Think there are two issues here: 

 

You are probably using an older ICS version that I am, there are a lot of OAuth changes in V8.71 including an embedded window so no browser needed, it is available in the overnight zip and many others are using it but won't be released until late May (and the Delphi 2010 packages are not done yet).  There is one bug fix that might be effecting you.  V8.71 has been tested by Delphi 2007 so should be okay on 2010. 

 

Also I don't really know what errors you are getting since you have not posted any proper logs, you can email them to me, but I'm not going to look closely unless they are from V8.71 and I can reproduce the error.

 

Angus

 

Share this post


Link to post
1 hour ago, Angus Robertson said:

they are from V8.71

I updated ICS.

 

"WebBrowser Title: Could not connect to this page."

 

With a different Redirect-URI

for example http://localhost:8080/microsoft/

I get the message:

AADSTS50011: The redirect URI 'http://localhost:8080/microsoft/' specified in the request does not match the redirect URIs configured for the application '8...

Azure settings attached. Of course, in Azure I also added such a setting - then there was a message as above. "Could not connect to this page."

 

Did I understand correctly, can I send more details to your private email?

 

J23

Authentication.png

Share this post


Link to post

Meanwhile I managed to send email using MS Graph API. The example project with full source code is described here:

 

Microsoft identity platform and OAuth 2.0 authorization code flow example for Daraja HTTP Framework

 

The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is a recommended OAuth 2.0 flow for native apps. No client secret is required in this flow. Instead, a secret is created by the calling application that can be verified by the authorization server.

 

The example application requests an authorization code, redeems the code for an access token, and then calls the Microsoft Graph API to retrieve user profile data, and to send an email on behalf of the signed-in user.

 

It may be a starting point for a ICS based application.

 

Edited by mjustin
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×