I am using mail.dll for reading emails. Earlier I was reading the emails from a gmail account and every thing was working alright. Now I need to move the application to another server and read mail from microsoft exchange.Below is the code that I am using
using (Imap imap = new Imap())
{
imap.Connect("server-name", port number);
imap.Login("username", "password");
imap.SelectInbox();
List<long> uids = imap.Search(Flag.Seen);
if (uids.Count > 0)
{
string eml = imap.GetMessageByUID(uids[0]);
IMail email = new MailBuilder().CreateFromEml(eml);
imap.GetMessageByUID(uids[0]);
lbResponse.Text = email.Subject;
}
else
{
lbResponse.Text = "No mails found";
}
imap.Close();
}
I have verified the port and server by using telnet and it is correct. But I get the "Unable to read data from the transport connection. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond " error. Please help.
Make sure that IMAP is enabled on your Exchange server:
http://technet.microsoft.com/en-us/library/bb124489.aspx
Also consider using:
imap.Search(Flag.Seen)
SearchFlag is obsolete in the latest version: http://www.limilabs.com/mail
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.