OpenPop.NET 클라이언트를 사용하여 Pop3 프로토콜을 통해 내 사서함에 액세스합니다. 한 가지를 제외하고 모두 괜찮습니다. 메시지를 삭제할 수 없습니다. 심지어 공식 사이트에서 sample 도움이되지 않습니다. 여러 메일 서버를 사용해 보았습니다. gmail.com, yandex.ru, rambler.ru 상황은 동일합니다.OpenPop.NET을 사용하여 메일 함에서 메시지 삭제
업데이트 코드. .Disconnect();
메소드가 호출 될 때 .DeleteMessage(messageNumber);
방법으로 표시되는 이메일
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.
}
}
종료 할 때 삭제되는 것을 읽었습니까? 시도해 보았 니? – Marco
물론. 샘플 페이지에서 코드를 시도했습니다. 혼자서'client.Disconnect()'를 호출하려고 시도했습니다. 아무 일도 없었습니다. – Seekeer
어떤 메시지 번호를 사용하고 있습니까? 나는 pop3이 0 기반이 아니라 1을 기반으로한다고 믿는다. 이 예제 코드는 나를 위해 일하고있다. 나는 그것을 매일 사용하고있다. 문제가 메시지 번호가 잘못 될 수 있다고 생각합니다. 메시지 번호는 세션 기반임을 유의하십시오. – Marcin