我正在使用 OpenPop DLL,它对我的项目非常有用,但是当我使用 Gmail 帐户时,我遇到了问题。阅读后我无法从 Gmail 中删除电子邮件。我正在使用以下代码和最新的 OpenPop DLL:
using (OpenPop.Pop3.Pop3Client pop3Client = new OpenPop.Pop3.Pop3Client())
{
// Connect to the server
pop3Client.Connect(
ConfigurationManager.AppSettings["host"],
Convert.ToInt32(ConfigurationManager.AppSettings["port"]),
Convert.ToBoolean(ConfigurationManager.AppSettings["useSsl"]));
// Authenticate ourselves towards the server
pop3Client.Authenticate(
ConfigurationManager.AppSettings["username"],
ConfigurationManager.AppSettings["password"],
AuthenticationMethod.UsernameAndPassword);
// Get the number of messages in the inbox
int messageCount = pop3Client.GetMessageCount();
if (messageCount > 0)
{
// We want to download all messages
allMessages = new List<Message>(messageCount);
// Messages are numbered in the interval: [1, messageCount]
// Ergo: message numbers are 1-based.
// Most servers give the latest message the highest number
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(pop3Client.GetMessage(i));
}
// Process all the messages and save in database
}
// On successful insert in database, delete the same message from email server
pop3Client.DeleteAllMessages();
pop3Client.Disconnect();
pop3Client.Dispose();
}
如果我在代码中做错了什么,你能告诉我吗?你的帮助将是可观的。