I'm using OpenPop DLL and it's working great for my project but i'm getting on issue when i'm using with Gmail Account. I'm not able delete the Email from Gmail after reading. I'm using following code and latest 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();
}
Can you please let me know if there's anything wrong i'm doing in code? You help will be appreciable.