gpt4 book ai didi

c# - 使用 OpenPop.NET 删除邮箱中的消息

转载 作者:行者123 更新时间:2023-11-30 15:04:33 25 4
gpt4 key购买 nike

我正在使用 OpenPop.NET 客户端通过 Pop3 协议(protocol)访问我的邮箱。一切都很好,除了一件事:我无法删除消息。连sample从官方网站没有帮助。我试过几个邮件服务器:gmail.com, yandex.ru, rambler.ru 情况都是一样的。

更新 - 添加代码。

static void Main(string[] args)
{
DeleteMessageOnServer("pop.gmail.com", 995, true, USERNAME, PASSWORD, 1);
}

public static void
DeleteMessageOnServer(string hostname, int port, bool useSsl, string username,
string password, int messageNumber)
{
// 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);

// Mark the message as deleted
// Notice that it is only MARKED as deleted
// POP3 requires you to "commit" the changes
// which is done by sending a QUIT command to the server
// You can also reset all marked messages, by sending a RSET command.
client.DeleteMessage(messageNumber);

// When a QUIT command is sent to the server, the connection between them are closed.
// When the client is disposed, the QUIT command will be sent to the server
// just as if you had called the Disconnect method yourself.
}
}

最佳答案

删除通过 .DeleteMessage(messageNumber); 方法标记的电子邮件发生在调用 .Disconnect(); 方法时。

关于c# - 使用 OpenPop.NET 删除邮箱中的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10090917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com