正在阅读 pop3 电子邮件,为什么没有收到已读电子邮件?

发布于 2024-11-26 15:16:32 字数 151 浏览 0 评论 0原文

我正在使用 C# 并使用 OpenPop.net 库从我的 Web 域读取电子邮件。

它正在读取电子邮件,但只收到新电子邮件。我想让它像 hotmail 一样,它应该获取已读和未读的信息,然后使用 CSS 我将以不同的方式显示它们。请指导我该怎么做。

谢谢

I'm reading emails from my web domain in C# and using OpenPop.net library.

It is reading email but it only get emails that are new. I want to make it like hotmail that it should fetch read and unread both then using CSS I will display them differently. Please guide me how I can do it.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱,才寂寞 2024-12-03 15:16:32

POP3 不是像 IMAP 那样的存储系统。

当您从 POP3 收到邮件时,它通常会从服务器中删除该电子邮件(永远)。这就是它的工作原理。

也许 OpenPOP 中有一个选项允许人们在检索后不删除服务器上的电子邮件。

POP3 is not a storage system like IMAP.

When you get mail from POP3 it normally deletes the email from the server (forever). That's just how it works.

Perhaps there is an option in OpenPOP that allows one not to delete the emails on the server after retrieval.

新人笑 2024-12-03 15:16:32

编辑:

我猜您正在尝试使用 POP3 从 gmail 检索邮件。 Gmail 有一些奇怪的非标准 POP3 行为。 Gmail 将隐藏已检索到的邮件并忽略 POP3 DELE 命令。
请参阅此相关问题 有关此行为的更多信息。

Openpop 示例之一展示了如何检索所有消息:

/// <summary>
/// Example showing:
///  - how to fetch all messages from a POP3 server
/// </summary>
/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
/// <param name="useSsl">Whether or not to use SSL to connect to server</param>
/// <param name="username">Username of the user on the server</param>
/// <param name="password">Password of the user on the server</param>
/// <returns>All Messages on the POP3 server</returns>
public static List<Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
    // The client disconnects from the server when being disposed
    using(Pop3Client client = new Pop3Client())
    {
        // Connect to the server
        client.Connect(hostname, port, useSsl);

        // Authenticate ourselves towards the server
        client.Authenticate(username, password);

        // Get the number of messages in the inbox
        int messageCount = client.GetMessageCount();

        // We want to download all messages
        List<Message> allMessages = new List<Message>(messageCount);

        // Messages are numbered in the interval: [1, messageCount]
        // Ergo: message numbers are 1-based.
        for(int i = 1; i <= messageCount; i++)
        {
            allMessages.Add(client.GetMessage(i));
        }

        // Now return the fetched messages
        return allMessages;
    }
}

Edit:

I'm guessing you're trying to retrieve mail from gmail using their POP3. Gmail has some weird non-standard POP3 behaviour. Gmail will hide messages that have been retrieved and ignores the POP3 DELE command.
See this related question for more information on this behaviour.

One of the Openpop examples shows how to retrieve all messages:

/// <summary>
/// Example showing:
///  - how to fetch all messages from a POP3 server
/// </summary>
/// <param name="hostname">Hostname of the server. For example: pop3.live.com</param>
/// <param name="port">Host port to connect to. Normally: 110 for plain POP3, 995 for SSL POP3</param>
/// <param name="useSsl">Whether or not to use SSL to connect to server</param>
/// <param name="username">Username of the user on the server</param>
/// <param name="password">Password of the user on the server</param>
/// <returns>All Messages on the POP3 server</returns>
public static List<Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
    // The client disconnects from the server when being disposed
    using(Pop3Client client = new Pop3Client())
    {
        // Connect to the server
        client.Connect(hostname, port, useSsl);

        // Authenticate ourselves towards the server
        client.Authenticate(username, password);

        // Get the number of messages in the inbox
        int messageCount = client.GetMessageCount();

        // We want to download all messages
        List<Message> allMessages = new List<Message>(messageCount);

        // Messages are numbered in the interval: [1, messageCount]
        // Ergo: message numbers are 1-based.
        for(int i = 1; i <= messageCount; i++)
        {
            allMessages.Add(client.GetMessage(i));
        }

        // Now return the fetched messages
        return allMessages;
    }
}
七婞 2024-12-03 15:16:32

因为 POP 标准行为是:

  • 下载消息、
  • 删除消息

,而 IMAP 标准行为是:

  • 下载消息、
  • 将消息留在那里。

只要您的 POP 库足够低级,您就可以随时更改该行为。

Because the POP standard-behaviour is:

  • download message
  • delete message

while the IMAP standard-behaviour is:

  • download message
  • leave message there

You can always alter that behavior, given your POP library is sufficiently low-level.

霞映澄塘 2024-12-03 15:16:32

您可以做的是,当您从 smtp 服务器获取电子邮件时,将所有电子邮件写入数据库,这样下次您打开应用程序时,您仍然可以阅读所有电子邮件。

通常邮件服务器会在客户端收到邮件后删除邮件(在 Outlook 和其他邮件客户端中,有一个特定的设置来打开/关闭此功能,也许 OpenPop lib 也有一个设置)

What you could do is write all emails to a database when you fetch them from the smtp server, so next time you open your application you can still read the all emails.

Usually mail servers delete the mail when a client has received it (in outlook, and other mail clients, there is a specific setting to turn this on/off, maybe OpenPop lib also has a setting for this)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文