Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: IMAP Error:index does not exist on server Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 12 September 2018 at 2:13pm | IP Logged Quote Sever

I am receiving the following error in the Mailbee Trace logs:
Error: The message with the specified index does not exist on the server.

Questions: What does this error mean? What index?


Details below.

I have a customer running an old version of our product.
Has been working for months without issues against their Microsoft Exchange Server 2010 IMAP4 endpoint.

What is odd is some emails download correctly.
I suspect emails sent directly to the inbox work. Email forwarded to inbox fail, but I don't have proof of this yet.


The following is a trace of a failed email.
--------------------

[11:54:56.92] [INFO] Assembly version: 7.2.4.366.
...
[11:54:57.41] [INFO] Select folder "INBOX".
[11:54:57.41] [SEND] MBN00000006 SELECT "INBOX"\r\n
[11:54:57.42] [RECV] * 1 EXISTS\r\n [Total 12 bytes received.]
[11:54:57.42] [RECV] * 1 RECENT\r\n [Total 12 bytes received.]
[11:54:57.42] [RECV] * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)\r\n [Total 61 bytes received.]
[11:54:57.44] [RECV] * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags\r\n [Total 91 bytes received.]
[11:54:57.44] [RECV] * OK [UNSEEN 1] Is the first unseen message\r\n [Total 45 bytes received.]
[11:54:57.44] [RECV] * OK [UIDVALIDITY 20390] UIDVALIDITY value\r\n [Total 44 bytes received.]
[11:54:57.44] [RECV] * OK [UIDNEXT 56793] The next unique identifier value\r\n [Total 55 bytes received.]
[11:54:57.44] [RECV] MBN00000006 OK [READ-WRITE] SELECT completed.\r\n [Total 47 bytes received.]
[11:54:57.46] [INFO] Will download envelopes.
[11:54:57.47] [SEND] MBN00000007 FETCH 1 (UID RFC822.SIZE BODY[])\r\n
[11:54:57.53] [RECV] MBN00000007 OK FETCH completed.\r\n [Total 33 bytes received.]
[11:54:57.55] [INFO] Envelopes downloaded
[11:54:57.58] [INFO] Error: The message with the specified index does not exist on the server.
[11:54:57.62] [SEND] MBN00000008 LOGOUT\r\n
[11:54:57.62] [RECV] * BYE Microsoft Exchange Server 2010 IMAP4 server signing off.\r\n [Total 64 bytes received.]
[11:54:57.62] [RECV] MBN00000008 OK LOGOUT completed.\r\n [Total 34 bytes received.]
[11:54:57.62] [INFO] Will disconnect from host "email.customer.com".
[11:54:57.62] [INFO] Disconnected from host "email.customer.com".

The code is similar to the following:
------------------------------------

imap.SelectFolder(folder); // in this case "INBOX"

int totalMessagesInFolder = imap.MessageCount;

if (totalMessagesInFolder > 0)
{
    for (int i = totalMessagesInFolder; i > 0; i--)
    {
        MailMessage message = imap.DownloadEntireMessage(i, false);

        // do something with message
        if (message.DateReceived == null)
        {
        }
     }
}

I had them turn on IMAP logging on their Microsoft Exchange Server 2010 IMAP4 server.
Here is the output.
------------------------

2018-09-12T15:54:56.913Z     00000000000000A5     0     127.0.0.1:143     127.0.0.1:65041   ;        -2147483648     0     53     OpenSession           

2018-09-12T15:54:56.944Z     00000000000000A5     1     127.0.0.1:143     127.0.0.1:65041   ;        0     22     132     capability       &nb sp;  R=ok

2018-09-12T15:54:57.007Z     00000000000000A5     2     127.0.0.1:143     127.0.0.1:65041   ;        46     20     43     starttls         ;  

2018-09-12T15:54:57.163Z     00000000000000A5     3     127.0.0.1:143     127.0.0.1:65041   ;        0     22     142     capability       &nb sp;  R=ok

2018-09-12T15:54:57.335Z     00000000000000A5     4     127.0.0.1:143     127.0.0.1:65041   ;   Product_User     109     51     399     authenticate      ;NTLM     R=ok;RpcC=14;LdapC=10;LdapL=94;Msg="User:Product_User:aa863e39-ed47-4ac7-9632-a60aa7c030fb:HHM Mailbox:CUST-MAIL.customer.com";Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/0%,FC:1000/0,Policy:DefaultThrottlingPolicy_feff67b2-72f8-4276-a573- c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

2018-09-12T15:54:57.351Z     00000000000000A5     5     127.0.0.1:143     127.0.0.1:65041   ;   Product_User     15     23     917     list     "" "*"     R=ok;RpcC=3;Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/0%,FC:1000/0,Policy:DefaultThrottlingPolicy_feff67b2-72 f8-4276-a573-c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

2018-09-12T15:54:57.397Z     00000000000000A5     6     127.0.0.1:143     127.0.0.1:65041   ;   Product_User     15     26     367     select     "INBOX "     R=ok;RpcC=7;RpcL=16;Rows=1;Recent=1;Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/1%,FC:1000/0,Policy:DefaultThrott lingPolicy_feff67b2-72f8-4276-a573-c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

2018-09-12T15:54:57.522Z     00000000000000A5     7     127.0.0.1:143     127.0.0.1:65041   ;   Product_User     78     44     33     fetch     1 (UID RFC822.SIZE BODY[] )     R=OK;RpcC=15;LdapC=4;LdapL=31;Rows=1;Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/1%,FC:1000/0,Policy:DefaultThrot tlingPolicy_feff67b2-72f8-4276-a573-c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

2018-09-12T15:54:57.585Z     00000000000000A5     8     127.0.0.1:143     127.0.0.1:65041   ;   Product_User     0     18     98     logout      &n bsp;   R=ok;Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/1%,FC:1000/0,Policy:DefaultThrottlingPolicy_feff67b2-72f8-4276-a573-c7d37 80db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

Thank you for looking at this.
Back to Top View Sever's Profile Search for other posts by Sever
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 12 September 2018 at 11:41pm | IP Logged Quote Alex

What if you repeat the same routine again? Maybe the problem disappears on the next session (when the message is no longer RECENT)?

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 13 September 2018 at 5:47am | IP Logged Quote Sever

Thanks for the suggestion.

The application is configured to run every 10 minutes. It fails repeatedly.   

Things we have tried.
We removed all emails for the INBOX. Sent an email directly to the INBOX and it works. They "forward" an email and the error occurs. I put "forward" in quotes because I have not received a clear explanation how they forward the messages.

I asked them to create a new folder INBOX\TEST. They drag a new email into it and we can download it. They drag a "forwarded" email and it fails.

Notice the fetch line in the imap log.

2018-09-12T15:54:57.522Z     00000000000000A5     7     127.0.0.1:143     127.0.0.1:65041   ; ;   Product_User     78     44      33     fetch     1 (UID RFC822.SIZE BODY[] )     R=OK;RpcC=15;LdapC=4;LdapL=31;Rows=1;Budget="Conn:0,HangingConn:0,AD:$null/$null/1%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/1%,FC:1000/0,Policy:DefaultThrot tlingPolicy_feff67b2-72f8-4276-a573-c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

It's response size is 33 bytes of data.   I believe the 33 bytes are as shown in the MailBee trace log:
MBN00000007 OK FETCH completed.\r\n

When the code successfully downloads an email the response size is much larger:
2018-09-12T14:06:47.770Z     000000000000009F     7     127.0.0.1:143     127.0.0.1:64537   ;   Product_User     78     44      80664     fetch     2 (UID RFC822.SIZE BODY[] )     R=OK;RpcC=8;RpcL=15;LdapC=3;Rows=1;Budget="Conn:0,HangingConn:0,AD:$null/$null/0%,CAS:$null/$null/1%,AB:$null/$null/0%,RPC:$null/$null/1%,FC:1000/0,Policy:DefaultThrottl ingPolicy_feff67b2-72f8-4276-a573-c7d3780db725,Norm[Resources:(DC)CUST-DC1.customer.com(Health:-1%,HistLoad:0),(Mdb)HHM Mailbox(Health:-1%,HistLoad:0),]"

Of course, they can view and download these emails just fine using the Outlook Web App...which is why they are pointing the finger at our application.

Back to Top View Sever's Profile Search for other posts by Sever
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 13 September 2018 at 6:38am | IP Logged Quote Alex

Perhaps, yet another IMAP bug in Exchange. OWA doesn't use IMAP so they can't see the bug there.

You may consider migrating to EWS instead of IMAP. The current version of MailBee.NET support it.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 13 September 2018 at 9:54am | IP Logged Quote Sever

We do support EWS in our current product version.
This customer is running on an version that only supports POP3 and IMAP.
We may have to go down the path of upgrading.


I was just curious what would cause: "Error: The message with the specified index does not exist on the server."

From what I can tell we are only getting 33 bytes back in response to the FETCH command: MBN00000007 OK FETCH completed.\r\n

When it works successfully, the response is much larger: 80000+.
So an exchange IMAP bug is possible.

The message says "index does not exist on the server". This message is confusing me. What index? Is this the error that is displayed when you get no data back after the "OK FETCH completed.\r\n" text?
Back to Top View Sever's Profile Search for other posts by Sever
 
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 13 September 2018 at 10:16am | IP Logged Quote Sever

Reading the IMAP specification it does say:

A non-existent unique identifier is ignored without any error message generated. Thus, it is possible for a UID FETCH command to return an OK without any data or a UID COPY or UID STORE to return an OK without performing any operations.

The key here is: it is possible for a UID FETCH command to return an OK without any data

So this means on the server the FETCH did not find the requested message.
So it returns: OK FETCH completed\r\b with no data.

Mailbee throws an exception with the message "Error: The message with the specified index does not exist on the server."

I still don't know why it can't find the message.
Back to Top View Sever's Profile Search for other posts by Sever
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 13 September 2018 at 11:33pm | IP Logged Quote Alex

You asked the server to return data for the message index #1. The server didn't return it. Therefore the message.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 14 September 2018 at 6:22am | IP Logged Quote Sever

Thank you Alex for responding.

I had incorrectly expected that the IMAP response would have been different. The IMAP spec said:

   Result:     OK - fetch completed
               NO - fetch error: can't fetch that data
               BAD - command unknown or arguments invalid

I assumed we would see NO or BAD if it could not fetch the data.
(This is the reason why we purchased MailBee. It handles all the protocol stuff for us.)


The question I have now is why isn't the message returned.
Is the following code incorrect?

imap.SelectFolder(folder); // in this case "INBOX"
int totalMessagesInFolder = imap.MessageCount;
if (totalMessagesInFolder > 0)
{
    for (int i = totalMessagesInFolder; i > 0; i--)
    {
        MailMessage message = imap.DownloadEntireMessage(i, false);
    }
}

I am downloading the message using the ordinal index. Is that bad?

Back to Top View Sever's Profile Search for other posts by Sever
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 14 September 2018 at 8:38am | IP Logged Quote Alex

Actually, if the server was acting correctly, it would have returned NO but it returned OK (although no data associated with the message being requested).

Your method seems OK, although I can recommend you to try another approach:

UidCollection uids = imap.Search();
for (int i = uids.Count - 1; i > -1; i--)
{
MailMessage message = imap.DownloadEntireMessage(uids(i), true);
}

Does it make any difference? It'a trial and error experience, some approach may work out while everything else won't. It's easy to write code when things work as expected but when they are not (like this weird Exchange's behavior) all you have to do is to treat it as a blackbox and be patient in finding the solution.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Sever
Newbie
Newbie
Avatar

Joined: 04 August 2016
Location: United States
Online Status: Offline
Posts: 11
Posted: 14 September 2018 at 9:28am | IP Logged Quote Sever

Alex…thank you very much for the sanity check, the suggestions, and your patience.

We use this code in a product we sell to customers. It allows them to download emails over IMAP4, POP3, or Exchange Web Services.
Almost every customer we sell to uses this code. Before MailBee supported Exchange Web Services...we strongly recommended the IMAP4 protocol.
Almost all our customers used IMAP. We rarely have issues beyond assisting getting the connection information correct.   

This is why I am so confused with this one Exchange Server.

I will look into creating a test app for this customer using your suggested approach.

Again, thank you for your knowledge and assistance.
Back to Top View Sever's Profile Search for other posts by Sever
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 14 September 2018 at 9:39am | IP Logged Quote Alex

Each new version of MS Exchange drops something in IMAP. For instance, new versions no longer support search anything but plain ASCII in IMAP (while older versions did this just fine). Perhaps they drop IMAP support completely someday.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide