Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

I am trying to read gmail emails via imap but whenever I connect to imap then I will get this error

An existing connection was forcibly closed by the remote host

Here is my code

Imap4Client imap = new Imap4Client();
           imap.Connecting += new ConnectingEventHandler(imap_Connecting);
           imap.Connected += new ConnectedEventHandler(imap_Connected);

           imap.ConnectSsl("", 993);
           imap.Login("", "xxxxxxx");
           int mailboxCount = imap.Mailboxes.Count;

Currently I am using API from codeplex. Can you guys tell me what i am doing wrong.


It could be firewall problem, or you have made too many connections to the server.

Check the below link once[^]
Share this answer
raghav.softobiz 10-Oct-13 6:06am    
No that is not the case
Share this answer
You can use Imapx Libraries.Using these libraries worked for me.The best one in IMAP i believe.[^]

If you are using these type of dlls and connecting to Gmail server then may be your organization firewall is blocking the inbound and outbound calls.This might be also because of your proxy settings.Recommends you to send a network support ticket in your organization:)
Share this answer
hello guys i need help about accessing gmail unread mails and after getting send these to gsm mobile as a message
plz help me
Share this answer
CHill60 20-Mar-15 9:47am    
If you have a question of your own use the red "Ask a Question" link at the top of the page. Do not post questions as solutions to old posts.
You will need to include your code and explain where you are stuck

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