question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntax error in BODY. Unexpected token: ')'

See original GitHub issue

Describe the bug

Hello. I have an old email with a reminder for a certain date sent using Gmail, once there was a normal email with an HTML body, but now for some reason it has disappeared and only the attached files remain.

When trying to execute folder.FetchAsync with fetchRequest(Message Summary Items.Full | Message Summary Items.UniqueId | MessageSummaryItems.PreviewText) an exception occurs (MessageSummaryItems.PreviewText).

image

C: A00000007 FETCH 56 (UID FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODYSTRUCTURE BODY.PEEK[HEADER.FIELDS (REFERENCES)])
S: * 56 FETCH (UID 683 FLAGS (\Seen $NotJunk NotJunk) INTERNALDATE "22-Oct-2020 11:42:46 +0000" RFC822.SIZE 3285 ENVELOPE ("Thu, 22 Oct 2020 14:42:46 +0300" "Accepted: Invitation: =?utf-8?Q?=D0=9F=D0=BE=D0=B2=D1=82=D0=BE=D1=80=D0=?=@ Wed Jan 13, 2021 15:00 - 16:00 (test@test.space)" ((NIL NIL "test" "test.space")) ((NIL NIL "test" "test.space")) ((NIL NIL "test" "test.space")) ((NIL NIL "test" "gmail.com")) NIL NIL NIL "<4054e02d-184d-48ea-a42c-1a7ce1afd22a@Spark>") BODYSTRUCTURE ((("text" "plain" ("charset" "utf-8") NIL NIL "7bit" 0 1 NIL ("inline" ("filename" "")) NIL NIL)(("text" "html" ("charset" "utf-8") NIL NIL "quoted-printable" 0 1 NIL ("inline" ("filename" "")) NIL NIL)("text" "calendar" ("charset" "utf-8") "<B4A0A860187D44DA8891F5C7997A690A>" NIL "quoted-printable" 716 20 NIL ("inline" ("filename" "")) NIL NIL) "related" ("boundary" "5f91703b_238e1f29_1e8") NIL NIL NIL) "alternative" ("boundary" "5f91703b_46e87ccd_1e8") NIL NIL NIL)("application" "ics" NIL NIL NIL "base64" 772 NIL ("attachment" ("filename" "reply.ics")) NIL NIL) "mixed" ("boundary" "5f91703b_3d1b58ba_1e8") NIL NIL NIL) BODY[HEADER.FIELDS (REFERENCES)] {2}
S: 
S: )
S: A00000007 OK FETCH Completed.
C: A00000008 UID FETCH 683 (BODY.PEEK[1.1]<0.512>)
S: * 56 FETCH (UID 683 BODY[1.1]<0> )
S: A00000008 OK UID FETCH Completed.

Exception

image

Unhandled exception. MailKit.Net.Imap.ImapProtocolException: Syntax error in BODY. Unexpected token: ')'
   at MailKit.Net.Imap.ImapFolder.FetchStreamAsync(ImapEngine engine, ImapCommand ic, Int32 index, Boolean doAsync)
   at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponseAsync(Boolean doAsync, CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapCommand.StepAsync(Boolean doAsync)
   at MailKit.Net.Imap.ImapEngine.IterateAsync(Boolean doAsync)
   at MailKit.Net.Imap.ImapEngine.RunAsync(ImapCommand ic, Boolean doAsync)
   at MailKit.Net.Imap.ImapFolder.FetchPreviewTextAsync(FetchSummaryContext sctx, Dictionary`2 bodies, Int32 octets, Boolean doAsync, CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapFolder.GetPreviewTextAsync(FetchSummaryContext sctx, Boolean doAsync, CancellationToken cancellationToken)
   at MailKit.Net.Imap.ImapFolder.FetchAsync(Int32 min, Int32 max, IFetchRequest request, Boolean doAsync, CancellationToken cancellationToken)
   at Test.Imap.Clients.BaseClient.Run() in /root/BaseClient.cs:line 57
   at Test.Imap.Services.InboxService.Start(ImapOptions options) in /root/Services/test.cs:line 29
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

Platform (please complete the following information):

  • OS: MacOS
  • .NET Runtime: CoreCLR
  • .NET Framework: net6.0
  • MailKit Version: 3.4.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TheSuunnycommented, Sep 13, 2022

@jstedfast Yes, everything works fine. Thank you 😃

1reaction
jstedfastcommented, Sep 13, 2022

Try the latest build from https://www.myget.org/feed/mimekit/package/nuget/MailKit and see if that works

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
How to Fix SyntaxError: Unexpected token < in JSON at ...
The SyntaxError: Unexpected token < in JSON at position 0 error indicates that JavaScript code received non-JSON data, usually HTML, instead of the...
Read more >
6/9: "SyntaxError: Unexpected token if"
Getting a syntax error means that there is a statement in your code that violates one or more of the syntactic (grammar) rules...
Read more >
SyntaxError: Unexpected token o in JSON at position 1
In express I was doing JSON.parse(response.data) which I had forgot was already parsed into json object hence causing this error. – Emile. Jan ......
Read more >
Syntax error in BODYSTRUCTURE. Unexpected token
One of our clients got fetch error with his gmail account: This is the stacktrace: MailKit.Net.Imap.ImapProtocolException: Syntax error in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found