一年前Mitchel Sellers有一个related的问题....NET Framework中的IMAP支持在哪里?
我想访问谷歌IMAP发送和接收我的自定义应用程序中的电子邮件。
问题是我不想使用任何第三方控件。
.Net Framework的较新版本支持IMAP?我有什么选择?
一年前Mitchel Sellers有一个related的问题....NET Framework中的IMAP支持在哪里?
我想访问谷歌IMAP发送和接收我的自定义应用程序中的电子邮件。
问题是我不想使用任何第三方控件。
.Net Framework的较新版本支持IMAP?我有什么选择?
Borland Delphi的Indy components曾经是ported to C#和.NET。据我所知,没有对此的本机支持。
没有.NET框架支持IMAP。你需要使用一些第三方组件。
尝试Mail.dll email component,这是非常经济实惠,易于使用:
using(Imap imap = new Imap())
{
imap.Connect("imapServer");
imap.Login("user", "password");
imap.SelectInbox();
List<long> uids = imap.SearchFlag(Flag.Unseen);
foreach (long uid in uids)
{
string eml = imap.GetMessageByUID(uid);
IMail message = new MailBuilder()
.CreateFromEml(eml);
Console.WriteLine(message.Subject);
Console.WriteLine(message.TextDataString);
}
imap.Close(true);
}
您可以在这里下载:http://www.lesnikowski.com/mail/。
我已经切换到Ubuntu以备将来的发展。有没有办法让这个库在Linux上与C#Mono一起工作或使用Vala编程语言? – 2014-07-13 23:44:04
在当前版本的.NET中没有IMAP支持,我还没有听说过有任何计划将这种支持添加到框架中。您必须尝试第三方组件之一。
您可以查看我们的Rebex Secure Mail。
下面的代码演示如何从Inbox
文件夹下载邮件:
// create client, connect and log in
Imap client = new Imap();
client.Connect("imap.example.org");
client.Login("username", "password");
// select folder
client.SelectFolder("Inbox");
// get message list
ImapMessageCollection list = client.GetMessageList(ImapListFields.Fast);
if (list.Count == 0)
{
Console.WriteLine("There are no messages in the mailbox.");
}
else
{
// download the first message
MailMessage message = client.GetMailMessage(list[0].SequenceNumber);
...
}
试用可以从www.rebex.net/secure-mail.net/
下载,您还可以享受Rebex Q&A forum运行在类似引擎这个网站。
和这里http://stackoverflow.com/questions/670183/accessing-imap-in-c和这里http://stackoverflow.com/questions/545724/using-c-net-librarires-to-check- for-imap-messages-from-gmail-servers,但仍然是相同的答案 – Will 2009-10-05 13:42:12
@Will还有万维网,因为SO – OrElse 2009-10-05 13:47:51