Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using (var imapClient = new ImapClient(host, userName, passWord, ImapClient.AuthMethods.Login, 993, true))
              {
                  if (type == "inbox")
                  {
                      imapClient.SelectMailbox("INBOX");
                  }
                  else if (type == "draft")
                  {
                      imapClient.SelectMailbox("[Gmail]/Drafts");
                  }
                  else if (type == "sent")
                  {
                      imapClient.SelectMailbox("[Gmail]/Sent Mail");
                  }
                  else if (type == "spam")
                  {
                      imapClient.SelectMailbox("[Gmail]/Spam");
                  }
                  else if (type == "trash")
                  {
                      imapClient.SelectMailbox("[Gmail]/Trash");
                  }
                  messages = new List<MailMessage>(imapClient.GetMessageCount());
                  int Msgcount = imapClient.GetMessageCount();
                  AllMsgCount = Msgcount;

                  if (Msgcount < NoRows)
                  {
                      messages = imapClient.GetMessages(0, Msgcount, false, seenUnseen).ToList();

                  }
                  else
                  {
                      if (lastMsgCount == 0)
                      {
                          lastMsgCount = 20;
                      }
                      lastMsgCount = Msgcount - lastMsgCount;
                      if (Msgcount >= 0)
                      {
                          if (tmpnorows > 0)
                          {
                              messages = imapClient.GetMessages(Msgcount, Msgcount + tmpnorows, false, seenUnseen).ToList();
                          }
                          else
                          {
                              messages = imapClient.GetMessages(Msgcount, Msgcount - 10, false, seenUnseen).ToList(); ;
                          }
                          //messages = imapClient.GetMessages(Msgcount, Msgcount - 20, false, seenUnseen)..Where(m => !m.Flags.HasFlag(Flags.Seen) && !m.Flags.HasFlag(Flags.Deleted)).ToList();

                      }
                  }
Posted
Updated 30-Oct-15 21:20pm
v2

you're using gmail - so you should try

telnet <your imap host address> 993 


to see if you get a response, and start tracing the network path from there to see if you have external connectivity/firewall issues
 
Share this answer
 
v3
ok fine thats code working fine due to some server hosting problam i got that type of error excepting some changes in gmail .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900