We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem in connecting to gmail account using IMapClient (C# .NET)

Error while Connecting to Gmail Account
AE_2_1_0002 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)
This is the error I’m getting while trying to connect to Gmail Account using Imap Server
Following is the code, Please tell me the problem in the code and the way to connect to Gmail Account using Imap Server

  string username = textBox1.Text.ToString().Trim();
            string password = textBox2.Text.ToString().Trim();
            //Aspose.Email.Clients.Imap.ImapClient imap = new Aspose.Email.Clients.Imap.ImapClient("imap.gmail.com", 993, "xxxx@gmail.com", "pas");
        
            try
            {
                // connect to gmail server
               
                ImapClient client = new ImapClient();

               // client.CreateConnection();
                client.UseDefaultCredentials = false;
                client.Host = "imap.gmail.com";
                client.Port = 993;                                                   
                client.Username = username;
                client.Password = password;
                
                client.EnableSupported = true;
                client.SecurityOptions = SecurityOptions.SSLImplicit;
                
               

                // Select the inbox folder and Get the message info collection

                try

                {

                    // ExStart:GettingFoldersInformation

                    // Get all folders in the currently subscribed folder

                    ImapFolderInfoCollection folderInfoColl = client.ListFolders();



                    // Iterate through the collection to get folder info one by one

                    foreach (ImapFolderInfo folderInfo in folderInfoColl)

                    {

                        // Folder name and get New messages in the folder

                       MessageBox.Show("Folder name is " + folderInfo.Name);

                        ImapFolderInfo folderExtInfo = client.GetFolderInfo(folderInfo.Name);

                       MessageBox.Show("New message count: " + folderExtInfo.NewMessageCount);

                       MessageBox.Show("Is it readonly? " + folderExtInfo.ReadOnly);

                       MessageBox.Show("Total number of messages " + folderExtInfo.TotalMessageCount);

                    }

                    // ExEnd:GettingFoldersInformation



                    // Disconnect to the remote IMAP server

                    client.Dispose();

                }

                catch (Exception ex)

                {
                  
                   MessageBox.Show("Error while creating Folders"+ Environment.NewLine+ex.Message);

                }

               MessageBox.Show(Environment.NewLine + "Getting folders information from IMAP server.");
                MessageBox.Show("done");
            }
            catch(Exception ex)
            {
               
                MessageBox.Show("Error while connecting to Gmail Account"+Environment.NewLine+ex.Message);
            }

Please help me to resolve the issue.

@ritadcc126,

I like to inform that code snippet you have shared includes some undeclared variables so would you please share your SSCCE code reproducing the issue so that we may try to reproduce and investigate it in our environment.

@ritadcc126,

I suggest you to please visit below link for sample code to connect Gmail account.

I have bee facing trouble while logging into my account after the install itunes on windows 7 and it was a real problem. Please help me to fix the problem so that I can use the application.

@stevewilliam007,

I have observed the issue shared by you. There is no connection between Aspose.Email and installation of ITunes. Can you please elaborate the issue related to Aspose.Email on your end.