Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6720631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:14:07+00:00 2026-05-26T09:14:07+00:00

I am trying to parse the response returned by IMAP that contains the content

  • 0

I am trying to parse the response returned by IMAP that contains the content of an email. How can I determine the start and end of the message returned from the response retrieved through IMAP?

Below are 2 examples of responses when I retrieve an email through IMAP:

. fetch 3728 body.peek[1]
* 3728 FETCH (BODY[1] {45}
Hello,
This is test message 1. 
:(
:)

)
* 3732 FETCH (FLAGS (\Seen \Recent))
* 3733 FETCH (FLAGS (\Seen \Recent))
. OK FETCH completed.

And the second retrieval:

. fetch 3729 body.peek[1]
* 3729 FETCH (BODY[1] {42}
Hello,
This is test message 2. :)

)
The above bracket is part of the message's content.

)
. OK FETCH completed.

First, both retrievals sometimes give different ending when new emails come into the account. Second, it seems like the message end of with a bracket and a . OK FETCH Completed response. But what happens if the content consists of brackets too? Then I may read the wrong bracket and never get the full content.

Like this, when parsing the response from IMAP, how should I interpret the response and get the content correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:14:07+00:00Added an answer on May 26, 2026 at 9:14 am

    You should read rfc 3501 …

    IMAP strings can be represented in 2 forms:
    1) Quotes string.
    2) string literal.

    String literal synatx:
    {number_of_bytes}CRLF
    — here you need read number of bytes. NOTE: BYTES not string !!!

    Also as IMAP specifications says: you need to be ready to parse any response at any time, also any string part can be string literal.

    Coding stable-full functional IMAP client not easy job.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse the location header of an HTTP response that is returned
when i try to parse the response returned from a web service i got
I am trying to parse a response data as html format. The data contains
I ran into a problem while trying to parse an XML string returned from
I'm trying to parse the xml response of http://api.hostip.info/?ip=12.215.42.19 with SimpleXML but I can't
I am trying to parse JSON response from a httpwebrequest fetch and a little
I'm trying to parse the xml document returned from this link but I get
I'm trying to parse the response from a web server. My parser does as
I'm trying to parse a json response data from youtube api but i keep
I am trying to parse an XML response from a website in C#. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.