开发者

string reading problem through IMAP

I am working on a IMAP, so just reading the body (body[header.fields (DATE FROM SUBJECT)]) I am passing this command.

But problem is like there some time my string return extra stuff excetp from my original string. and some times I had getting limited part of the string means half part of the body. so whenever I am passing second command it will accept as a first command and return result as the first command pending resul.;

so the my concern is that I am not able to retrive proper data as of the part of the body.

as per my knowladge I think it's happen due to the internet datapacket tresfersize, but apart from this look at outlook or any other mail manager w开发者_Python百科ill work properly so what this is the mechanisam for this data retriving.

or anything else to do fo my coding.....

Thanks..


Posting a sample response from the IMAP server that contains the "extra stuff" would help.

The problem you are most likely facing is with untagged server responses.

Heres what RFC3501 says:

Status responses can be tagged or untagged. Tagged status responses indicate the completion result (OK, NO, or BAD status) of a client command, and have a tag matching the command:

C: a002 NOOP
S: a002 OK NOOP completed

Some status responses, and all server data, are untagged. An untagged response is indicated by the token "*" instead of a tag.

C: a047 NOOP
S: * 22 EXPUNGE
S: * 23 EXISTS
S: * 3 RECENT
S: * 14 FETCH (FLAGS (\Seen \Deleted))
S: a047 OK NOOP completed

So you need to distinguish between those 2 response types.

Please remember that checking if every received line starts from '*' character is not enough, as your email message may also have lines starting from star character:

C:    a004 fetch 12 body[header]
S:    * 12 FETCH (RFC822 {342}
S:    Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)
S:    From: Terry Gray <gray@cac.washington.edu>
S:    Subject: IMAP4rev1 WG mtg summary and minutes
S:    MIME-Version: 1.0
S:    
S:    * This is email body containing start char
S:    )
S:    a004 OK FETCH completed

{342} is the exact number of bytes you are supposed to read.

The bottom line is don't reinvent the wheel use existing library.

You can check out mine IMAP component (not free).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜