We are using VB and accessing Outlook object model from our application to send emails. We receive the following error message when the Send method of the Outlook email object is called:

Please note that our email functionality is wrapped inside a DLL. Strangely, if we copy and paste the same code into an executable, we noticed that it works fine. The process only fails when it is done from within a DLL.
This started to happen in Outlook 2019 since we upgraded it to version 16.0.13929.20206. We have updated Outlook to the latest version 16.0.14026.20202 today but nothing has changed and the process still fails. We are using 32-bit version of Outlook.
Even a simple code of:
1) Create email object.
2) Set the body to "test"
3) Set subject to "test"
4) Set the recipient email address and resolve
5) Set sent on behalf of address
6) Send the email
Fails with the same error message from within our DLL. We have no idea why the same simple code works from within an executable but fails when it is wrapped inside a DLL.
We also inactivated any add-ins that we could and that did not help. We also started Outlook in safe mode and that did not help either.
We would greatly appreciate any help.