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)
using (Imap imap = new Imap()) { //Pass Host Name as string for connection imap.ConnectSSL("imap.gmail.com"); //Pass Credential for Gmail account for Login Use Login() Method imap.UseBestLogin("abc@gmail.com", "XXXXXX"); //Select Folder as of Now i am selecting Inbox Folder FolderStatus _folderStatus = imap.SelectInbox(); //Find all Unseen Message Set to Flag Property List<long> uids = imap.SearchFlag(Flag.Unseen); foreach (long uid in uids) { //Download Message Based On UID byte[] eml = imap.GetMessageByUID(uid); //Parse Download MEssage IMail imail = new MailBuilder().CreateFromEml(eml); Console.WriteLine(imail.Subject); Console.WriteLine(imail.TextDataString); } imap.Close();
First log in to the specified account via the web browser, you might have received an email with the blocked attempt information. Review it - you might need to confirm it was you.
There are several ways of dealing with this error:
Please note that contrary to what the label says those applications (such as Thunderbird, Outlook and Mail.dll) are secure – they use TLS or SSL to secure the communication. The label name Gmail uses is misleading and false.
Use OAuth 2.0 (OAuth 2.0 for installed applications, OAuth 2.0 for web applications, OAuth 2.0 for service accounts)
Use application specific passwords (You can find how to create one in the Gmail support site)
In some cases you'll need to use unlock captcha (use incognito mode so you are sure you are logged in to correct account): https://accounts.google.com/DisplayUnlockCaptcha
Here are more information on how to enable IMAP in Gmail. https://www.limilabs.com/blog/enable-imap-in-gmail