Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outlook 365 OAuth2

trial03

Technical User
Oct 9, 2011
15
MY
Hi master,

Microsft Exchange Online will permanently remove support for Basic authentication with Client Submission (SMTP AUTH) in September 2025.



Could anyone provide a vfp sample to send mail by 365 OAuth2?

Thanks and best regards,
 
Trial03,

My single advice to you is to acquire the Chilkat API.

Examples regarding the use of OAuth2 with VFP: https://www.example-code.com/foxpro/oauth2.asp.
Dear Sir,

I appreciate your input. It is very helpful.

Before acquire the Chikat Api. Would you mind sharing a sample code and explaining how to set it up in Azure? I just want to make sure I understand the process, as I'm not a professional, and I cant find a direct VFP msOffice oAuth2 sample in the link https://www.example-code.com/foxpro/oauth2.asp.

Thanks and Regards,
 
1747203462180.png
2nd and 3rd Example on the page.

Sorry, I can't help you with the full process, as I don't have Azure at my disposal and I won't register there just to guide you through the processes necessary within Azure (registering an app, for example).

The whole authorization process could be much simpler, if you use a Mail client and automate it via MAPI.
 
I just want to make sure I understand the process, as I'm not a professional
How far are you involved in writing code for the FoxPro application? If you're not a programmer, you won't settle this without programming a new feature, you can't just change a few options or settings and be done with this.
 
Last edited:
View attachment 2238
2nd and 3rd Example on the page.

Sorry, I can't help you with the full process, as I don't have Azure at my disposal and I won't register there just to guide you through the processes necessary within Azure (registering an app, for example).

The whole authorization process could be much simpler, if you use a Mail client and automate it via MAPI.
 
Dear Sir,

Thanks for reply.

I already read the 2nd and 3rd Example on the page, but lack of eMail sending by using https://graph.microsoft.com/v1.0/users/{sender}/sendMail.

I try follow the

GMail SMTP Send using Previously Obtained OAuth2 Access Token

but it is not working with the error :

SMTP XOAUTH2 authentication
  • Your JWT is issued for Microsoft Graph API ("aud":"https://graph.microsoft.com"), but you're trying to authenticate with Outlook SMTP (smtp.office365.com) which requires a token issued for https://outlook.office365.com.
  • You're using client credentials flow, which does not work with SMTP unless very specific conditions are met (and it's extremely limited).





  • Now try figure out how to send it by using https://graph.microsoft.com/v1.0/users/{sender}/sendMail or workable method.
    Hopefully can get a sample code for VFP + msOffice365 oAuth2 for sending email.
    Thanks and regards,






 
The answer is in the error message, isn't it? You need a token issued for https://outlook.office365.com


Regarding using graph API: As far as I googled and learned MS graph API allows you to send a mail on behalf of one user. You can't use Graph to simply send an email with any sender to Exchange via code. It's therefore not really a "Send-Mailmessage" replacement, if you want to use it that way.

On the other hand, if you don't need your code to be able to send mails on behalf of any Exchange account you also only need Graphs mail sending method and that announcement wasn't about a change of Graph.

Taking it from my alltime experience with multiple organisations including a mail feature in their FoxPro applications, all they ever needed was sending mail on behlaf of the application user. That means sending mails for all employees of the company, but each only for them. You don't need that general access, usually.

>You're using client credentials flow
That points out you want to send mail for one user. Well, then you bark up the wrong tree. Did you actually used this up to now and did authentication stop working?
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top