Fetched Emails not ordered when I use pop3
First I were Fetching emails by POP3 using this library OpenPop.Pop3 and it was working ok and it was returns emails ordered from last email to first email
but when I change the library to mailkit library the returned messages not ordered and couldn't know based on what mailkit order fetched emails
that's my code after I change to mailkit library
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate((username), password);
int messageCount = client.Count;
// We want to download all messages
List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);
for (int i = messageCount-1; i > 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
}
by this way allmessages variable should contains emails ordered from last email to first email but that's not happened emails not ordered at all
although I were using the same authenticated email before with OpenPop.Pop3 and fetched emails were ordered
c# gmail pop3 mailkit
add a comment |
First I were Fetching emails by POP3 using this library OpenPop.Pop3 and it was working ok and it was returns emails ordered from last email to first email
but when I change the library to mailkit library the returned messages not ordered and couldn't know based on what mailkit order fetched emails
that's my code after I change to mailkit library
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate((username), password);
int messageCount = client.Count;
// We want to download all messages
List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);
for (int i = messageCount-1; i > 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
}
by this way allmessages variable should contains emails ordered from last email to first email but that's not happened emails not ordered at all
although I were using the same authenticated email before with OpenPop.Pop3 and fetched emails were ordered
c# gmail pop3 mailkit
add a comment |
First I were Fetching emails by POP3 using this library OpenPop.Pop3 and it was working ok and it was returns emails ordered from last email to first email
but when I change the library to mailkit library the returned messages not ordered and couldn't know based on what mailkit order fetched emails
that's my code after I change to mailkit library
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate((username), password);
int messageCount = client.Count;
// We want to download all messages
List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);
for (int i = messageCount-1; i > 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
}
by this way allmessages variable should contains emails ordered from last email to first email but that's not happened emails not ordered at all
although I were using the same authenticated email before with OpenPop.Pop3 and fetched emails were ordered
c# gmail pop3 mailkit
First I were Fetching emails by POP3 using this library OpenPop.Pop3 and it was working ok and it was returns emails ordered from last email to first email
but when I change the library to mailkit library the returned messages not ordered and couldn't know based on what mailkit order fetched emails
that's my code after I change to mailkit library
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate((username), password);
int messageCount = client.Count;
// We want to download all messages
List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);
for (int i = messageCount-1; i > 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
}
by this way allmessages variable should contains emails ordered from last email to first email but that's not happened emails not ordered at all
although I were using the same authenticated email before with OpenPop.Pop3 and fetched emails were ordered
c# gmail pop3 mailkit
c# gmail pop3 mailkit
edited Nov 15 '18 at 14:04
jstedfast
18.9k25177
18.9k25177
asked Nov 14 '18 at 15:14
sabreen sabersabreen saber
267
267
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I don't know why they wouldn't be ordered for you since MailKit is not doing any kind of sorting.
That said, MailKit uses 0-based indexes while I suppose OpenPOP.NET must have used 1-based indexes, so your loop should make the following change:
for (int i = messageCount-1; i >= 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
Perhaps this will produce the expected results?
Update: It turns out that MailKit was correctly downloading the messages in reverse order just as his code was trying to do (as mentioned in his follow-up question). The problem this user was facing is that his GMail account settings were only providing MailKit's Pop3Client with a subset of his total Inbox as is explained in Google's FAQ in the section titled "Emails aren't downloading correctly", where it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
- In your email client's POP settings page, find the "Email address" or
"User name" field.
- Add recent: in front of your email address. For example,
recent:example@gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.
– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303349%2ffetched-emails-not-ordered-when-i-use-pop3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't know why they wouldn't be ordered for you since MailKit is not doing any kind of sorting.
That said, MailKit uses 0-based indexes while I suppose OpenPOP.NET must have used 1-based indexes, so your loop should make the following change:
for (int i = messageCount-1; i >= 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
Perhaps this will produce the expected results?
Update: It turns out that MailKit was correctly downloading the messages in reverse order just as his code was trying to do (as mentioned in his follow-up question). The problem this user was facing is that his GMail account settings were only providing MailKit's Pop3Client with a subset of his total Inbox as is explained in Google's FAQ in the section titled "Emails aren't downloading correctly", where it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
- In your email client's POP settings page, find the "Email address" or
"User name" field.
- Add recent: in front of your email address. For example,
recent:example@gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.
– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
add a comment |
I don't know why they wouldn't be ordered for you since MailKit is not doing any kind of sorting.
That said, MailKit uses 0-based indexes while I suppose OpenPOP.NET must have used 1-based indexes, so your loop should make the following change:
for (int i = messageCount-1; i >= 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
Perhaps this will produce the expected results?
Update: It turns out that MailKit was correctly downloading the messages in reverse order just as his code was trying to do (as mentioned in his follow-up question). The problem this user was facing is that his GMail account settings were only providing MailKit's Pop3Client with a subset of his total Inbox as is explained in Google's FAQ in the section titled "Emails aren't downloading correctly", where it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
- In your email client's POP settings page, find the "Email address" or
"User name" field.
- Add recent: in front of your email address. For example,
recent:example@gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.
– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
add a comment |
I don't know why they wouldn't be ordered for you since MailKit is not doing any kind of sorting.
That said, MailKit uses 0-based indexes while I suppose OpenPOP.NET must have used 1-based indexes, so your loop should make the following change:
for (int i = messageCount-1; i >= 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
Perhaps this will produce the expected results?
Update: It turns out that MailKit was correctly downloading the messages in reverse order just as his code was trying to do (as mentioned in his follow-up question). The problem this user was facing is that his GMail account settings were only providing MailKit's Pop3Client with a subset of his total Inbox as is explained in Google's FAQ in the section titled "Emails aren't downloading correctly", where it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
- In your email client's POP settings page, find the "Email address" or
"User name" field.
- Add recent: in front of your email address. For example,
recent:example@gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
I don't know why they wouldn't be ordered for you since MailKit is not doing any kind of sorting.
That said, MailKit uses 0-based indexes while I suppose OpenPOP.NET must have used 1-based indexes, so your loop should make the following change:
for (int i = messageCount-1; i >= 0; i--)
{
var msg = client.GetMessage(i);
allMessages.Add(msg);
}
Perhaps this will produce the expected results?
Update: It turns out that MailKit was correctly downloading the messages in reverse order just as his code was trying to do (as mentioned in his follow-up question). The problem this user was facing is that his GMail account settings were only providing MailKit's Pop3Client with a subset of his total Inbox as is explained in Google's FAQ in the section titled "Emails aren't downloading correctly", where it states:
After you set up POP in your Gmail settings, your emails become available
in batches. It might take a while to see all your emails.
Note: Gmail downloads a copy of every email you send or receive, except
for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't
download emails sent within your mail client, but you can still see them
if you log in to Gmail.
If you continue to have problems downloading emails, try using recent
mode:
- In your email client's POP settings page, find the "Email address" or
"User name" field.
- Add recent: in front of your email address. For example,
recent:example@gmail.com.
If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.
edited Nov 15 '18 at 13:15
answered Nov 14 '18 at 17:36
jstedfastjstedfast
18.9k25177
18.9k25177
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.
– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
add a comment |
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.
– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
0 should return last entered email , but the problem this code not order emails !!
– sabreen saber
Nov 15 '18 at 8:23
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
I just need to fetch always the new emails
– sabreen saber
Nov 15 '18 at 8:59
client.GetMessage(0)
returns the oldest message stored on the POP3 server.– jstedfast
Nov 15 '18 at 11:35
client.GetMessage(0)
returns the oldest message stored on the POP3 server.– jstedfast
Nov 15 '18 at 11:35
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
Why do you think they aren't "sorted" properly? What are you using as a basis for this claim? POP3 uses indexes to refer to messages. MailKit uses indexes to refer to messages. There is no sorting that is happening at all inside MailKit.
– jstedfast
Nov 15 '18 at 11:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303349%2ffetched-emails-not-ordered-when-i-use-pop3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown