Mail.dll通过代理C#

时间:2010-07-12 20:13:17

标签: c# email

我有以下任务:我应该阅读来自gmail的电子邮件,并且计算机通过代理连接到互联网。通常我会像这样使用mail.dll http://www.lesnikowski.com/mail

    using (Imap imap = new Imap())
    {
        imap.ConnectSSL(_server);
        imap.Login(_user, _password);

        // Select the Inbox folder, ou can also select other folders.
        // E.g. Sent folder: imap.Select("Sent");
        imap.SelectInbox();

        // Find all unseen messages:
        List<long> uidList = imap.Search(Flag.All);


        // Download each message:
        foreach (long uid in uidList)
        {
            IMail email = new MailBuilder().CreateFromEml(
                imap.GetMessageByUID(uid));

            // Display email data, save attachments:
            ProcessMessage(email);                    
        }
        imap.Close(true);
    }

但是当需要代理和授权时我该怎么办? 谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

Mail.dll支持 SOCKS4 SOCKS4a SOCKS5 HTTP 代理:

ProxyFactory factory = new ProxyFactory();
IProxyClient proxy = factory.CreateProxy(ProxyType.Socks5, "69.139.119.66", 1144);
Socket socket = proxy.Connect("imap.gmail.com", Imap.DefaultSSLPort);

using (Imap imap = new Imap())
{
    imap.AttachSSL(socket, "imap.gmail.com");

    // regular imap code

    imap.Close();
}

请记住添加对Mail.dll和Proxy.dll的引用。

您可以在此处下载支持代理的最新版本: http://www.limilabs.com/mail