How email using OAuth and Exchange Online

Philip Tulett philip.tulett at
Sat Jul 16 09:03:24 UTC 2022

Hi Mike,

Now you mention it, I do remember an issue with the $completed. It too nested within subclasses. 
I am calling the following line in the $construct:-
Do iPop3.$setCallingInst($cinst)
I found $completed was being called and setting the value of an instance variable with pRow. This is after a Do iPop3.$run()
However, when I came to use the instance variable its value was null.
In my case as I ended up setting a class variable in the $completed and then immediately after the Do iPop3.$run(), set the instance variable to the value of the class variable.
This works in my case as I am using the $run and not $start, and it is within an Omnis Runtime not an Omnis Web Server.

I intended to try setting the calling instance just after the $init, as in the following
Do iPop3.$init(.....)
Do iPop3.$setCallingInst($cinst)
Do iPop3.$run(),
But was running tight on time to deliver for the client and have not had a chance to go back resolve instance variable issue, so I have left it as is and is working fine in Production.

I am using 10.2 31315 on Windows Server 2022.

Kind regards
Philip Tulett

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at> On Behalf Of Mike Matthews - Omnis via omnisdev-en
Sent: 16 July 2022 07:17
To: OmnisDev List - English <omnisdev-en at>
Cc: Mike Matthews - Omnis <omnis at>
Subject: Re: How email using OAuth and Exchange Online

Hello Philip,

Thank you for the hint on how to save the state of the tokens using $save, I was having a problem there.

I’m having trouble with the oAuth2 OW3 at the moment.  The $complete is not being called, either for the standard version, or the redirected version using Calculate iOAUTH2.$callbackinst as $cinst.

Our window class is buried a few levels deep within 3 layers of sub classes and sub windows, and I have tried many options, but no luck yet.  I can get it to work in a test window that works all on it’s own, so my system is good to go, just not in production.

I’m using v10.2 build 31416 with OSX 12 on a M1 MBP.



On 12 Jul 2022, at 09:36, Philip Tulett <philip.tulett at<mailto:philip.tulett at>> wrote:

Hi Michael,

I have multiple apps that are connecting to Exchange / O365 to send and retrieving messages using ow3 objects.

>From what you have said, you are just sending emails, at this time MS are continuing to support Basic Auth for SMTP Sending:-
That said, if you are going to refactor the code to use the new worker object, it would be worth going to OAUTH at the same time.

Generally, MS tokens have a life of about an hour, so expect to receive an updated token at that rate, that will need to be saved for next connection, so capture the call to $tokensrefreshed and then save the OAUTH buffer using Do iOAUTH2.$save(iSavedOAUTHBuffer,iKey) Returns lOK I encrypt the OAUTH buffer with a key, then save it to a binary field in the database so can be used at the next call or if the apps stops and restarts.
So, when starting a connection, I load the latest OAUTH buffer from the database.
To reduce user interaction/reauthorisation, when setting up the in AZURE, include the following tin the Scope API:- offline_access,1,7LtfYImCiExRBGy_CwzGP4CsFLs8cFBWyEa8cKOx7Dss_MY7_0W7UGXNouDCPg3iSO8RmO7dRWdCmrlpt_6HhkspOKwIXFbqYv46s-0qDPZ1QfCZZw,,&typo=1
I my case I also include,1,NZaenVcEfz0u16K-qKJHtCkNiS-jngz7jzjyDA0E7cEJO_FX7prauhBddhDnbeaFCKATRwNGM3gKM-wvwTFErkhTbFFkusGfeq13Xjv7&typo=1,1,e8Agh-BTwpZgk0GTdsJ9hE73hSAJ7yv68DKjPFJWTZPoJCWVbo7GyJEmzt7bd8mJ6EFxelNzGwRx7ytnF8wsITMVm8WGd19qd9WKtEBlDr2gH3iZbF7u54kklpXH&typo=1
The above will need to be include in your initial Authorization request If you have multiple servers that could perform the token refresh, make sure that you include them in all the Redirect URI's in AZURE.
If you will be using the Omnis Runtime's I recommend setting a unique static port for each of them (see above on Redirect URI's) in their server options "RESTful connections"


Kind regards
Philip Tulett

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at> On Behalf Of Michael Houlberg
Sent: 11 July 2022 19:07
To: OmnisDev List - English <omnisdev-en at>
Subject: Re: How email using OAuth and Exchange Online


Thanks, I’m sure I’ll be talking with you in the future.  I see that right now I should probably make the move from SMTPSend to oSMTPWorker as a first step, since I already know how to do that.

Michael Houlberg
Houlberg Development, LLC

On Jul 11, 2022, at 11:04 AM, Mike Matthews - Omnis via omnisdev-en <omnisdev-en at> wrote:

I’m in the middle of using oAuth2 for Exchange / O365 / Azure.

Most done, just need to tidy up.

Mike Matthews

Lineal Software Solutions
Commercial House, The Strand<x-apple-data-detectors://1/1> Barnstaple, Devon, EX31 1EU<x-apple-data-detectors://1/1>

omnis at<mailto:mike.matthews at>,1,u1D0bbNxVtBgEh6oOxIRUI_b41leuut2zmVKX70EYJBdPlgQEBII765eku0Y8uIUP44mOfiSM4Crx8aY6wAz7lB3SuTZyFesTS8JA-TkHKh22A,,&typo=1<,1,5zjRvhRlZZunj0a11WXeLzcJpnYDfE2_XpgSvcc52lycHAXvJ2sR7v81fEsR0GGE6fDA77kzRZupdapK8U9BC11gmKS7RLyQdq_Nf9vEOa0aFu3tHIH1Y0YUtQ,,&typo=1>,1,HcWlb1Eya_H7OhQKKDQJWXu20EJydowdpNYG0Bj1b5wJv-bO7WZGe1YS9sib15J5V4RkbCCplClgYMYJXgnJwEZESpb8GrvLaEhn8mkJKQrrm77-GIDC3A,,&typo=1<,1,3lyDTIyhl13K1x8yPZBwpMa8ErFPS2zqa3wxMkIfDttSYjTUoVQxmgyyU6E4z9lXzXKcYmyYx8ry6iIh5ZgGDpcS_HHo5RoYd2mU2_8WFt6Dv_G3DjAX0rL8&typo=1>

On 11 Jul 2022, at 18:55, Michael Houlberg <michael at<mailto:michael at>> wrote:


My client who is part of a University, tells me that this fall they are dropping support for the type of email we have been using in favor of Exchange Online and using OAuth to authenticate.  Currently we send lots of emails using SMTPSend.  For another client I have had experience using the oSMTPWorker object.  But I haven’t had to deal with either oAuth or Exchange Online Server.

Does anyone have some pointers on this they can share?

Michael Houlberg
Houlberg Development, LLC
Manage your list subscriptions at
Start a new message -> mailto:omnisdev-en at

Manage your list subscriptions at,1,LEN0BqayhFuANxqJveNE9oq4dvm9PFhQao1v9024Lap4UwdKIdbJqufY4Fz9joOxqMo6_YMNS0KUyIKK2fJh2HSehNiziHstGweuItjPjcMC5rGZ8DVXn4qM&typo=1 Start a new message -> mailto:omnisdev-en at

Manage your list subscriptions at,1,40dyCF4DWrIXstitCJ9iHInZ9J1ya5B34uRTMtMqWBcmcDuj0utaL2BrntrLD_9XYSuRXM7XwCsC3dSv3GBhdmbX4UWwv6TQmidBDG1ePhgJ&typo=1 Start a new message -> mailto:omnisdev-en at

Manage your list subscriptions at,1,cLacmXQian6oe-9xRQiT5P_4ODxmrG-gWRyzfFk_wziz7LNKjV-02AcB1mf0SAbiMwaktzdHIpZvZM4oVr_FN-0r5V4GRtnqkmBAeLmo16sx&typo=1
Start a new message -> mailto:omnisdev-en at

Manage your list subscriptions at Start a new message -> mailto:omnisdev-en at 

More information about the omnisdev-en mailing list