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

  • Home
  • SEARCH
  • 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 6835943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:17:39+00:00 2026-05-26T23:17:39+00:00

i have data that i fetch from an email server i want to eliminate

  • 0

i have data that i fetch from an email server i want to eliminate noise and parse date and subject of incoming data and output it to users in a textview

how should we fetch data from an email server?

incoming data is like

something....
something...
* OK [PERMANENTFLAGS ($Submitted $XAOL-SENT \Answered \Deleted \Draft \Flagged \Seen $Forwarded $MDNSent Forwarded XAOL-GOOD XAOL-GOODCHECK-DONE)] Permanent flags
. OK [READ-WRITE] SELECT completed
. fetch 1:* (body[header.fields (from subject date)])
* 1 FETCH (BODY[HEADER.FIELDS (FROM SUBJECT DATE)] {149}
Date: Mon, 07 Nov 2011 17:00:25 -0500 (EST)
From: "AOLWelcomeInfo" <AOLWelcomeInfo@message.aol.com>
Subject: Welcome to Your New Email Account!

)
. OK FETCH completed

i use this code to parse it

NSMutableData* data = [[NSMutableData alloc] init];
    unsigned char c;
    for (;;) {
        recv(socket_, &c, sizeof(c), 0);
        if (c == '\n') {
            NSString* s = [[NSString alloc] initWithData: data
                                                encoding: NSUTF8StringEncoding];

            NSRange range = [s rangeOfString:@"FETCH "];
            if( range.location != NSNotFound ) {


            NSMutableArray *substrings = [NSMutableArray new];
                NSScanner *scanner = [NSScanner scannerWithString:s];
                [scanner scanUpToString:@"}" intoString:nil];
                while(![scanner isAtEnd]) {
                    NSString *substring = nil;
                    [scanner scanString:@"}" intoString:nil];
                    if([scanner scanUpToString:@"*" intoString:&substring]) {
                        // If the space immediately followed the }, this will be skipped
                        [substrings addObject:substring];
                    }
                    [scanner scanUpToString:@")" intoString:nil]; // Scan all characters before next }
                }
                NSString *email;
                [emailList addObject:@"Select an Email"];
                for(int i=0; i<substrings.count;i++){
                    email = [substrings objectAtIndex:i];
                    [emailList addObject:email]; // add emails in emailList
                }

                NSLog(@"%@",emailList);
                [substrings release];
            }

My output from NSlog is like

"Select an email"
"Select an email"

when i debug it it enters if statement but i couldn’t figure out why it doesnt parse it correctly.

it should be like :

"Select an email"
Date: Mon, 07 Nov 2011 17:00:25 -0500 (EST)
    From: "AOLWelcomeInfo" <AOLWelcomeInfo@message.aol.com>
    Subject: Welcome to Your New Email Account!)
  • 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-26T23:17:40+00:00Added an answer on May 26, 2026 at 11:17 pm

    the problem was i was reading data by one line each time in for(;;){} so every time when NSString S gets one line without parsing it i was deleting everything inside i changed whole parsing method to

    NSMutable array to UITableview when button clicked

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

Sidebar

Related Questions

I have a database with tables and values. I want to fetch that data
I have console application. In that i have some process that fetch the data
I have a WCF service that accesses a SQL database to fetch data .
I have been trying to add data from my ajax query that returns json
I have a table filled with data from my database, and i want a
I have some code that written in php to use for export data from
I have data that is organized in kind of a key-key format, rather than
I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study:
I have data that I would like to compute some statistics with. The data
For an XML file I am creating I have data that contains a bullet

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.