开发者

How can we fetch mail from Inbox, sent folder using POP3 in objective C

I am using CFNetwork to connect to my POP3 account on Yahoo.

I've written the code of connection and authentication which is running perfectly.

I have used CFStream to read the POP3 server response.

My question is, how can I access the specific folder like Inbox, sent folder or delete开发者_开发技巧 folder of my yahoo account using POP3 command.

I have to read the mails from the folder and show the list in the specific folder at local IPhone.

kindly help me to solve the issue.

Thanks in advance.


The POP3 protocol is documented in RFC 1939 - Post Office Protocol. It does not support the concept of folders.

In fact they mention in section 8:

Of course the other capabilities of IMAP, such as polling an existing connection for newly arrived messages and supporting multiple folders on the server, are not present in POP3.

IMAP on the other hand does, and is likely what you are looking for. It is well documented in http://www.faqs.org/rfcs/rfc3501.html The command in IMAP to choose a folder is called 'SELECT.' The protocol looks like this:

           C: A142 SELECT INBOX
           S: * 172 EXISTS
           S: * 1 RECENT
           S: * OK [UNSEEN 12] Message 12 is first unseen
           S: * OK [UIDVALIDITY 3857529045] UIDs valid
           S: * OK [UIDNEXT 4392] Predicted next UID
           S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
           S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited
           S: A142 OK [READ-WRITE] SELECT completed

If you are doing this as an intelectual exercise, you are going to need to rewrite your networking code to implement IMAP instead of POP. However if you are doing this as part of a commericial endevaur, I would recommend against writing an email client from scratch -- it is a solved problem with lots of freely avaiable source out there. You might want to look at the UW-IMAP toolkit, a free C Library or VMIME A C++ Library. Both should be able to work on the iOS platform without too much hassle.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜