Hy,
I am retrieving mails from a gmail account programaticaly using this libraries http://mailsystem.codeplex.com/ .
Everything it's OK (I get the messages count and a list of all messages) when I run my application for the first time after I set the 'Enable POP for all mail' to OK in the 'Forwarding and POP/IMAP' tab in Settings menu. But when I run it again no messages are being retrieved. And if I go again and set the enable POP for all mail, the application works again.
I think I have to set 'enable POP for all mail' programaticaly before I run the retrieving messages code.
Does anyone have any idea how can I do this programaticaly in C# and asp.net?
The code I'm using:
Pop3Client pop = new Pop3Client();
try
{
Label7.Text = string.Format("Connection to the pop 3 server : {0}", "pop.gmail.com ");
pop.ConnectSsl("pop.gmail.com", 995, TextBox4.Text, TextBox5.Text);
Label7.Text += string.Format("Message Count: {0}", pop.MessageCount.ToString());
MessageCollection mc = new MessageCollection();
for (int n = 1; n < pop.MessageCount + 1; n++)
{
Message newMessage = pop.RetrieveMessageObject(n);
mc.Add(newMessage);
Label7.Text += string.Format("Message ({0}) : {1} ", n.ToString(), newMessage.Subject);
}
}
catch (Pop3Exception pexp)
{
Label7.Text = string.Format("Pop3 Error: {0} ", pexp.Message);
}
catch (Exception ex)
{
Label7.Text = string.Format("Failed: {0} ", ex.Message);
}
finally
{
if (pop.IsConnected)
{
pop.Disconnect();
}
}
And I'm using the ActiveUp.Net.Mail library from the source I've mentioned before.