I want to read emial from my gmail account. I am using "OpenPop.Pop3" to read email from my gmail account, I am using below code :-
using OpenPop.Pop3;
public DataTable ReadEmailsFromId()
{
DataTable table = new DataTable();
try
{
using (Pop3Client client = new Pop3Client())
{
int messageCount = client.GetMessageCount();
for (int i = messageCount; i > 0; i--)
{
table.Rows.Add(client.GetMessage(i).Headers.Subject, client.GetMessage(i).Headers.DateSent);
string msdId = client.GetMessage(i).Headers.MessageId;
OpenPop.Mime.Message msg = client.GetMessage(i);
OpenPop.Mime.MessagePart plainTextPart = msg.FindFirstPlainTextVersion();
string message = plainTextPart.GetBodyAsText();
}
}
}
return table;
}
But its fetching emails before 4 March 2016, Not fetching new/latest emails. Is there any restriction in "OpenPop.Pop3" or am I missing something?
Select Internet Email and click on Next. Enter your name and email address at user information. Select POP3 for the account type and enter pop.mail.com as incoming server and smtp.mail.com as outgoing server. Enter your mail.com email address and password as log in credentials.
What Are Fetch Emails? With Fetch Email (POP3), your Emails are kept in the server until the client asks for it. Your Email won't be in the server for very long since the client will usually ask for it after a few minutes.
To get new emails just put up keyword "recent:" before username then it will give emails which has been received in the last 30 days.
using OpenPop.Pop3;
public DataTable ReadEmailsFromId()
{
DataTable table = new DataTable();
try
{
using (Pop3Client client = new Pop3Client())
{
client.Connect("pop.gmail.com", 995, true); //For SSL
client.Authenticate("recent:Username", "Password", AuthenticationMethod.UsernameAndPassword);
int messageCount = client.GetMessageCount();
for (int i = messageCount; i > 0; i--)
{
table.Rows.Add(client.GetMessage(i).Headers.Subject, client.GetMessage(i).Headers.DateSent);
string msdId = client.GetMessage(i).Headers.MessageId;
OpenPop.Mime.Message msg = client.GetMessage(i);
OpenPop.Mime.MessagePart plainTextPart = msg.FindFirstPlainTextVersion();
string message = plainTextPart.GetBodyAsText();
}
}
}
return table;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With