开发者

Automatically parse email contents and display in UI?

In my app, I want to be able to get a daily e-mail, and have the app display the contents of that e-mail. A new e-mail would come every weekday and it would only show the current e-mail.

Is there any way I could set up a special e-mail address that would receive the daily e-mails and then po开发者_JAVA百科pulate a custom user interface, such as a UITableView?


Your app would have to pull the data from the web server and the you would parse and display it yourself. (You can't push that info to a device.)

I suspect that you're trying to update your app by using an email account, so you probably want a server as a "middleman" for several reasons:

  1. Security - You don't want to have every copy of your app have your special email's login info coded in it. That is asking for trouble.

  2. Convenience - It is probably easier to parse the email on a server anyhow.

If you want to do something like this, follow these steps:

  1. Create an endpoint, or endpoints on your server to get the data from. (An endpoint is a URL that returns a piece of data in a(n expected) format, such as JSON or XML.) Your server will receive the email and parse it. Then you should store it in a database, so it's easier to manage later.

  2. Your app will make an HTTP request to the endpoint or endpoints. If you define multiple endpoints (say, one for each table row) then you will need multiple HTTP requests. (For HTTP requests, I recommend using ASIHTTPRequest). You should store your data in an array, so you can easily handle the table view later on.

  3. Next, you parse the data. If you made multiple requests in step 2, then you might not need this step. Replace any stored data with parsed data if necessary. Again, I suggest an array for ease of working with a table view.

  4. Populate your table view. You're done.

If you want to use email data directly, then for replace steps 1 & 2 with this:

  • Log in to your email account and access the email for today's date. I haven't done email login, so I can't help you much here. What I do know is that the latest trend in security is to use OpenID for security (which would be a counterargument to my first reason not to directly access email). Also, depending on the provider, you might have an API to access their email service. You should start by looking at that.


Mailgun has an API that parses incoming email and POSTs it into your application. Also Postmarkapp and Cloudmailin are able to do this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜