Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error in BODYSTRUCTURE. Unexpected token: NIL #919

Closed
neobgd opened this issue Sep 26, 2019 · 2 comments
Closed

Syntax error in BODYSTRUCTURE. Unexpected token: NIL #919

neobgd opened this issue Sep 26, 2019 · 2 comments
Labels
compatibility Compatibility with existing software server/office365 Microsoft Exchange Online (aka Office365) server-bug The bug appears to be in the server

Comments

@neobgd
Copy link

neobgd commented Sep 26, 2019

When I try to fetch Message summary I got this error:
Syntax error in BODYSTRUCTURE. Unexpected token: NIL

The code which I use is:

var inbox = client.Inbox;
inbox.Open(FolderAccess.ReadOnly);
int index = Math.Max(inbox.Count - a.received_last, 0);
foreach (var summary in inbox.Fetch(index, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure |MessageSummaryItems.Flags)){};

When I remove MessageSummaryItems.BodyStructure everything is fine.
I am using latest version 2.3.1.6

IMAP log is in the attach.
imap.zip

@jstedfast
Copy link
Owner

The problem is that the Exchange server is sending a bad BODYSTRUCTURE response.

Here's the first occurrence:

S: * 37 FETCH (UID 67 FLAGS (\Seen \Recent) RFC822.SIZE 14801 ENVELOPE ("Tue, 9 Jul 2019 13:53:17 +0200" "Verify your Apple ID email address" (("Apple" NIL "appleid" "id.apple.com")) NIL ((NIL NIL "appleid_usen" "email.apple.com")) ((NIL NIL "milan.tanasic" "evocon.rs")) NIL NIL NIL "<[email protected]>") BODYSTRUCTURE (("text" "plain" ("charset" "ISO-8859-1") NIL NIL "QUOTED-PRINTABLE" 850 31 NIL "inline" NIL NIL)("text" "html" ("charset" "ISO-8859-1") NIL NIL "QUOTED-PRINTABLE" 14692 502 NIL "inline" NIL NIL) "alternative" ("boundary" "----=_Part_45280395_786508794.1562673197246") NIL NIL))

In both the text/plain and the text/html body parts, it is sending "inline" instead of ("inline" NIL):

("text" "plain" ("charset" "ISO-8859-1") NIL NIL "QUOTED-PRINTABLE" 850 31 NIL "inline" NIL NIL)

According to the specs:

body-type-1part = (body-type-basic / body-type-msg / body-type-text)
                  [SP body-ext-1part]
body-type-text  = media-text SP body-fields SP body-fld-lines
body-ext-1part  = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang
                  [SP body-fld-loc *(SP body-extension)]]]
                    ; MUST NOT be returned on non-extensible
                    ; "BODY" fetch
body-fld-dsp    = "(" string SP body-fld-param ")" / nil

The body-fld-dsp syntax is not being satisfied in the response given.

@jstedfast jstedfast added the compatibility Compatibility with existing software label Sep 26, 2019
jstedfast added a commit that referenced this issue Sep 26, 2019
@jstedfast jstedfast added the server-bug The bug appears to be in the server label Nov 24, 2019
@jstedfast jstedfast added the server/office365 Microsoft Exchange Online (aka Office365) label Dec 28, 2024
@jstedfast
Copy link
Owner

Based on the greeting, I think this was Office365's version of Exchange but I could be wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with existing software server/office365 Microsoft Exchange Online (aka Office365) server-bug The bug appears to be in the server
Projects
None yet
Development

No branches or pull requests

2 participants