0 votes

All I am trying to do is to have my application read the subject and main body from an email sent to a gmail account. I have enabled SSL, enabled imap in the gmail imap settings, enabled a mode where any application can gain access, and yet it continues to give me this error:

An unhandled exception of type 'Limilabs.Client.IMAP.ImapResponseException' occurred in Mail.dll

Additional information: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)

The username and password for the account are correct and if i change them to anything else, it says the credentials are invalid.

The code throws the exception above on the third line of this code:

Using imap As New Imap()
imap.ConnectSSL("imap.gmail.com")
imap.UseBestLogin("username@gmail.com", "password")
End Using

Why on earth am i getting this exception?
Thank you.

by
closed by
I assume the problem is that "Access for less secure apps" is not turned on. You need to enable this setting or use OAuth2.
i tried access for less secure apps. whats Oauth2?
OAuth2 is an authorization standard/protocol for authorization. You can find OAuth 2.0 samples here:
https://www.limilabs.com/mail/samples#imap-gmail-oauth2
In most cases application specific password and less-secure applications are much more simpler to implement.
...