0

我的 IMAP 身份验证有一个奇怪的问题。如果我尝试使用字符串变量,我无法进行身份验证。我真的需要输入我的帐户和密码,这对我来说真的没有意义。

这不起作用!

    using (var client = new ImapClient(new ProtocolLogger("imap.log")))
        {

            using (var cancel = new CancellationTokenSource())
            {
                //LogIn
                client.Connect("imap.gmail.com", 993, MailKit.Security.SecureSocketOptions.SslOnConnect);
                var credentials = new NetworkCredential(username, password);
                client.Authenticate(credentials, cancel.Token);


                var personal = client.GetFolder(client.PersonalNamespaces[0]);
                f1.tbl_folderTableAdapter1.Insert(ID, PARENTID, username);

                client.Disconnect(true);
            }
        }

但这项工作

  using (var client = new ImapClient(new ProtocolLogger("imap.log")))
        {

            using (var cancel = new CancellationTokenSource())
            {
                //LogIn
                client.Connect("imap.gmail.com", 993, MailKit.Security.SecureSocketOptions.SslOnConnect);
                client.Authenticate("funnyemailhere", "anothernicepasswordhere");


                var personal = client.GetFolder(client.PersonalNamespaces[0]);
                f1.tbl_folderTableAdapter1.Insert(ID, PARENTID, username);

                client.Disconnect(true);
            }
        }

你能看出这里有什么问题吗?

先感谢您

4

0 回答 0