【问题标题】:Where is the IMAP support in the .NET Framework?.NET Framework 中的 IMAP 支持在哪里?
【发布时间】:2010-12-03 22:57:56
【问题描述】:

一年前,Mitchel Sellers 有一个related 的问题...

我想访问 Google IMAP 以在我的自定义应用程序中发送和接收电子邮件。

关键是我不想使用任何第三方控件。

.Net Framework 的较新版本支持 IMAP?我有什么选择?

【问题讨论】:

标签: .net imap email


【解决方案1】:

当前版本的 .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,它在与本网站类似的引擎上运行。

【讨论】:

    【解决方案2】:

    没有对 IMAP 的 .NET 框架支持。您需要使用一些第 3 方组件。

    试试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 编程语言?
    【解决方案3】:

    Borland Delphi 以前是 Indy components,以前是 ported to C# 和 .NET。

    据我所知,没有本地支持。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多