Fetching mails from outlook.com with IMAP fails
AdvancedNotifier opened this issue · comments
I'm trying to fetch UniqueIds from the imap-mail.outlook.com
server with the following code:
folder.Fetch(0, 1, MessageSummaryItems.UniqueId, cancellationToken);
This failes with the exception:
MailKit.Net.Imap.ImapCommandException: "The IMAP server replied to the 'FETCH' command with a 'NO' response: The specified message set is invalid."
The log shows to me:
C: A00000006 FETCH 1:2 UID
S: * 1 FETCH (UID 5)
S: A00000006 NO The specified message set is invalid.
What do I wrong? The same code works fine for me for Gmail
Now it works. Seems, it was a temporary server problem.
The problem occurred again.
The reason for this is max
parameter of the Fetch
call. If I change it to -1
, it works and the log shows:
C: A00000006 FETCH 1:* UID
So not all servers accept a range with the FETCH
command. I don't know, if you want to add a hint to your documentation.
All IMAP servers support ranges. Most likely what is happening is that your max value is larger than the number of messages in the folder.
Like I told you, you are wrong. But you are too ignorant to accept this.
Maybe you can enlighten me with your brilliance by showing me in the IMAP protocol specifications where not all IMAP servers allow ranges?
I'll wait.
You are too ignorant and selfish to recognize any mistake inside your thoughts.
... all I know is that I didn't lie to you with the mentioned log.
Btw: No software is bug free, so no software fulfills every protocol specification.
You are too ignorant and selfish to recognize any mistake inside your thoughts.
You are only proving yourself to be a massively ignorant asshole.
... all I know is that I didn't lie to you with the mentioned log.
I never said you lied to me with your log. Where did you get that idea?
All I said was that what is likely to be happening is that there are less than 2 messages in the folder and so the range 1:2
is perhaps causing the server to say "NO: invalid range".
You didn't paste the IMAP server response to the EXAMINE
or SELECT
command, so I can't see how many messages exist in the folder, so all I could do was propose a theory as to why that might have gotten the response that it did.
The fact that you got an untagged FETCH response for message index 1 means that there is probably only 1 message in the folder, but you asked for 2:
folder.Fetch(0, 1, MessageSummaryItems.UniqueId, cancellationToken);
That code is supposed to result in the following command (and from your log, MailKit did exactly what it was supposed to do):
A00000006 FETCH 1:2 UID
Keep in mind that MailKit uses 0-based indexes (e.g. 0, 1, 2, 3, 4, 5, ...) whereas IMAP uses 1-based indexes (e.g. 1, 2, 3, 4, 5, 6, ...)
So when you ask for the message range 0 to 1, that translates to messages 1 to 2 in IMAP.
In other words, if you only want to ask for message index 1, you'd use this line of code:
// fetch ranges are inclusive, so if we only want the first message, then we need to use the range 0:0 which translates to 1:1 in IMAP
folder.Fetch(0, 0, MessageSummaryItems.UniqueId, cancellationToken);
-or-
folder.Fetch(new int[] { 0 }, MessageSummaryItems.UniqueId, cancellationToken);
Are you now getting that ah-hah moment?
Maybe now you won't be so quick to accuse others of being ignorant when it is in fact you that was ignorant.
I found another guy, how have this problem with outlook server.
Are you now getting that ah-hah moment?
Yes: You are much more ignorant and selfish, I thought before. You cannot accept, that you are not perfect.
Yes: You are much more ignorant and selfish, I thought before. You cannot accept, that you are not perfect.
I see you like to project your own failings onto others.
I've tried to help you, that's not selfish of me. That's selfish of you for demanding my help (while also insulting me).
I'm also not the one who is ignorant of the IMAP specifications. That would be you.
Btw: No software is bug free, so no software fulfills every protocol specification.
All MailKit's ImapClient does is to translate the inputs you give it into the corresponding IMAP command. You are the one that provided the message set of 1:2
and so that's what MailKit sent to the IMAP server.
If the IMAP server doesn't accept that command, then what do you want MailKit to do about it?
What you need to do is handle ImapCommandException
and then try again with a different message set (i.e. index range).
I'm trying to fetch UniqueIds from the
imap-mail.outlook.com
server with the following code:folder.Fetch(0, 1, MessageSummaryItems.UniqueId, cancellationToken);
This failes with the exception:
MailKit.Net.Imap.ImapCommandException: "The IMAP server replied to the 'FETCH' command with a 'NO' response: The specified message set is invalid."
... this is the behavior of Outlook since a long time. (I don't know if it was every different from now.)
IMAP specifications.
... not every software implements all specifications as well, and every software has multiple bugs. A good software handles this, since nobody and nothing is perfect.
... this is the behavior of Outlook since a long time. (I don't know if it was every different from now.)
Can you elaborate on what the incorrect behavior is that Exchange has (it's not Outlook, because Outlook is a client and not an IMAP server).
From both your case and the case you linked to in node-imap, the NO The specified message set is invalid.
responses have been to invalid requests made by the developers.
In your case, you asked for the range 1:2
when there was no message 2.
In the node-imap case, the user fixed his issue by fixing his requested sequence range as well:
Done, the problem was with the source range, I used
imap.seq.fetch("*", options)
and worked with gmail but it didn't work with hotmail/outlook so i changed it to"1:*"
If you read the IMAP specifications, you'll quickly see that *
is indeed an invalid range. 1:*
is the correct syntax which is what he changed it to and then it worked for him.
In MailKit, the way you would request 1:*
is:
folder.Fetch(0, -1, ...);
The -1
value maps to *
.
I believe, your thinking is bad: You don't try to understand anything, you are telling other people your opinion.
And your questions are not really questions, you ask them only, to tell yourself to make everything right.
But there is no "right or wrong". There is nothing in the world, what is right or wrong.
The sense of the life is, that we're doing the best with everything the life offers to us.
You don't try to understand the server from Microsoft, and you don't try to handle the differences between the Microsoft server and other servers.
You also do not try to hunt the problem, I told you in another issue (folder.Open memory issue).
I believe a good man tries to understand other people, tries to find solution inside our not perfect world and hunt problems in his own code, before telling the problem based on the code of other people.
... but with this, you can't feel to be important and perfect. But you are trying to think this from yourself. So I believe, you should change your way of thinking, before I will answer your questions.
Please stop using MimeKit and MailKit.
Please stop commenting here or on any of my projects.
Please stop insulting me.
Please stop skirting my bans by creating new accounts only to continue harassing me.
Please stop demanding that I help you. I will not. Ever.
You blocked me twice, since you wanted to ignore my postings... and you believe, not to be ignorant.
You ignore my with using MailKit, but you believe not to be ignorant.
Furthermore, you are closing the very most issues immediately, since you don't want to try to assist other humans - but you believe not to selfish.
Sorry, but you're confirmed to be selfish and ignorant by yourself, but you are too ignorant and selfish to detect this.
Indeed, I will use MailKit further more and indeed I will ask you further more about assistance - you can't prevent this otherwise than stopping to offer this project and support for it. But you need this project, to believe you would be important. Every selfish human needs to believe this...