Ich benutze OpenPop.NET-Client, um Zugriff auf meine Mailbox über Pop3-Protokoll. Alles ist in Ordnung, außer einer Sache: Ich kann keine Nachrichten löschen. Auch sample von der offiziellen Website hilft nicht. Ich habe es mit mehreren Mail-Servern versucht: gmail.com, yandex.ru, rambler.ru Situation ist das gleiche.Löschen Sie Nachricht in Mailbox mit OpenPop.NET
Update - Code hinzugefügt.
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.
}
}
Haben Sie gelesen, dass das Löschen auftritt, wenn Sie beenden? Hast du versucht? – Marco
Natürlich. Ich habe Code von der Beispielseite ausprobiert. Versuchte Anruf 'client.Disconnect()' von mir selbst - nichts passierte. – Seekeer
Welche Nachrichtennummer verwenden Sie? Ich glaube pop3 ist 1 basiert nicht 0 basiert. Dieser Beispielcode funktioniert für mich. Ich benutze es jeden Tag. Ich denke das Problem kann falsche Nachrichtennummer sein. Bitte beachten Sie, dass die Nachrichtennummer sitzungsbasiert ist. – Marcin