使用imap阅读Gmail电子邮件 [英] Read gmail emails using imap
本文介绍了使用imap阅读Gmail电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过使用imap阅读gmail电子邮件
我从搜索中获取了这些代码
使用(Imap imap = new Imap())
{
imap .Connect( imap.gmail.com); // 或ConnectSSL
imap.UseBestLogin( ******** @ gmail.com, *******跨度>);
imap.SelectInbox();
列表< long> uids = imap.Search(Flag.Unseen);
List< MessageInfo> infos = imap.GetMessageInfoByUID(uids);
foreach (MessageInfo info in infos)
{
MessageBox。显示( 主题: + info.Envelope.Subject);
MessageBox.Show( From: + info.Envelope.From);
MessageBox.Show( To: + info.Envelope.To);
foreach (MimeStructure附件 info.BodyStructure.Attachments)
{
MessageBox.Show(attachment.SafeFileName);
}
break ;
}
imap.Close();
}
但我在imap.Connect(imap.gmail.com)中有这个例外;
尝试以其访问权限禁止的方式访问套接字74.125.24.108:143
我不明白我必须连接什么?
解决方案
您看到的消息通常意味着您在前往服务器的路上有一个被阻塞的端口...
这里的端口是143(非安全IMAP协议的默认端口)...
当Google请求受到保护时,您还需要使用端口993(用于安全IMAP协议的端口)连接...
Hi,
I want to read gmail emails by using imap
I got those code from searching
using (Imap imap = new Imap())
{
imap.Connect("imap.gmail.com"); // or ConnectSSL
imap.UseBestLogin("********@gmail.com", "*******");
imap.SelectInbox();
List<long> uids = imap.Search(Flag.Unseen);
List<MessageInfo> infos = imap.GetMessageInfoByUID(uids);
foreach (MessageInfo info in infos)
{
MessageBox.Show("Subject: " + info.Envelope.Subject);
MessageBox.Show("From: " + info.Envelope.From);
MessageBox.Show("To: " + info.Envelope.To);
foreach (MimeStructure attachment in info.BodyStructure.Attachments)
{
MessageBox.Show(attachment.SafeFileName);
}
break;
}
imap.Close();
}
but I've this exception in imap.Connect("imap.gmail.com");
An attempt was made to access a socket in a way forbidden by its access permissions 74.125.24.108:143
I don't understand I must connect to what?
解决方案
The message you see mostly means that you have a blocked port in your way to the server...
The port here is 143 (the default port for not-secured IMAP protocol)...
It is also very possible that you need to use port 993 (the port for secured IMAP protocol) as Google request secured connection...
这篇关于使用imap阅读Gmail电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文