Does Mail.dll require the scope: https://mail.google.com?
If you want to use IMAP/POP3/SMTP and OAuth2 authentication with Gmail, this is the scope you should be using.
You can find more details on how to use OAuth2, Gmail and Mail.dll here:
https://www.limilabs.com/blog/oauth2-gmail-imap-web-applications
https://www.limilabs.com/blog/oauth2-gmail-imap-installed-applications
https://www.limilabs.com/blog/oauth2-gmail-imap-service-account
Alternatively you can use less secure apps or application specific passwords .