Parsing and Receiving Email in iOS - ios

Suppose I have an email address that only receives a specific type of email, i.e. an automatically generated receipt email from a transaction.
I would like to build an iOS app to receive the email text from this email address and parse according to a predefined format and display the results. Is it possible to do this without dealing with the email server directly from the app?
Meaning can I for instance piggyback off the native mail client (assuming it is set up to receive pushed email sent to the email address). I tried looking through Apple's docs for iOS but could not find anything useful. Anyone know of something?

3rd party apps have no way to integrate with the Mail app or to make use of any configured mail account the user has setup on the device.
However, you can write an app that can access external email accounts if the user provides all of the usual email account details. The App Store has several 3rd party mail apps that serve as replacements for Apple's Mail app.
If your app is written to work with a specific email account, and not one entered by the user of the app, then you can hardcode all of the account details in the app.
Your app is basically a run of the mill email client. You just have to know how to access IMAP or POP3 accounts, retrieve the emails, and process them as needed.
Again, there is no way your app can intercept or make use of any emails accessed by any email accounts the user has setup for use with the standard Mail app.

There are at least two aspects to your question:
How do I get an email to open in my iOS app?
Put the data in an attachment and see this link
What format can I use in an email attachment to transport persistent
objects?
I've had decent results with NSKeyedArchive as an interchange format. There are lots of other choices, depending on what generates the receipts attachments.
Post a followup with your choices. Good luck!

Related

Trigger Request for Slack's Magic Login Email

I'm building a small email app (on iOS first) for internal team use only. We also have a Slack team that I'm rolling out to the whole group (about 250 people) around the same time I'm launching the app.
I'm going to have a lot of older and tech-phobic users, so I'm trying to make things as easy as possible for them. Since I'm writing the email app, I figure to making on-boarding even easier I can:
Check if they've got the Slack app installed (via the canOpenURL method)
Send them to the App Store to download if they don't
Open the Slack app for them if they do
Look for the magic login email
Automatically open the URL from the email.
All that is great, but it would be fantastic if I could trigger sending that email automatically and don't even need to send them to manually put in the team URL and their email. Anybody know a way?
CLARIFICATION:
One big reason I want to do this that I didn't make very clear is that when the Slack app sends the email it prompts you to go to your email app to receive your login link, but since iOS doesn't allow changing the default email app, it will send them to the wrong one for my user's purposes.
Sure. If you already have the emails of your target group you can generate the invitation mails programmatically with a small script.
You will need to use the undocumented API method users.admin.invite for that.

Open an email in the native iOS email application from a webpage

I'd like to create an email "file" (i.e. stored on my webserver) that can be accessed through a link on a webpage and which will open the native iOS email program and have the To, CC, BCC, Subject and Body filled in. Additionally I'd like the email to have an attachment. Is this possible?
If you are referring to the usage of <a href="mailto:someone#somwehere.com"> then I'm afraid the answer is no. More details in this question/answer.
This can be done, though it requires the use of PhoneGap/Cordova. This however, requires an iOS app containment. You can have the app communicate with your server. I'm assuming though, that you have a server hosted webapp and require this functionality.
If this is the case, the standard way to do this is to send the email on the server side. This of course, will not use the native iOS email application. If you don't have access to you own mail server, you can use a gmail account as an SMTP server. If your server is written in Java you can use JavaMailSender. If your server is written in Ruby, use the Mail gem. If your server is written in node, use NodeMailer. Most popular languages will have a Mail Library suitable for you needs.

Sending email without showing email composer view in ios 7

I'm making an iOS app and the user has to enter their info to register for an account. I'm wanting to make it so that it sends an email to the provided email account with the info that they just entered. But I don't want them to be able to see the email view. Is there a way to send an email in the background in iOS 7? I'm familiar with the SMTP Gmail workaround but I was wondering if there was anything more generic.
There is no documented API available using which you can perform this.
send this detail to your server via web service and than server will send the email using that detail.

Way to up incoming and outgoing mail for a custom mobile app

I am used to building apps in larger infrastructures. In a startup, how do I setup SMTP for a mobile app? Is there a place I can use for hosting this?
There are a couple of possible approaches:
One option is to not attempt to interface with SMTP/IMAP/POP servers directly in your app. You can, alternatively, send emails from your app via MFMessageComposeViewController, which gives you a standard compose email user interface. This is very easy to do.
To handle inbound emails you can let the user receive their emails via the standard Mail app (that way users don't have to go to different places to receive their emails). You integrate inbound emails with your app using a custom URL scheme. You can then send the user an email using this custom URL scheme, and if they get the mail on their iOS device and have that app installed, when they click on the link they will be taken to your app, passing it information from the URL in the email.
For example, if you defined a custom URL scheme of yourapp://, you can just include a hyperlink to that URL in your email (or text message or your web site), and if the user is on their iOS device, when they click on that link, they'll be taken to your app. If you google "iOS custom URL scheme tutorial", you'll see examples of the plist entries you need to make in your app for it to respond to a custom URL scheme. The Implementing Custom URL Schemes reference shows you what sort of changes you need to make to your app delegate to actually pass data in your custom URL to your app.
Alternatively, you can (a) sign up with any Internet Service Provider (ISP) that offers mail hosting; (b) write an app that sends email by connecting to that ISP's SMTP server; and (c) retrieve email by connecting to that ISP's IMAP or POP servers. Clearly you'll have to pay fees to the ISP, the quality of your app is linked to the quality of the ISP you partner with (so pick a good one), and you'll have to do your own SMTP/IMAP/POP integration in your app (and you'll have to write your own code to do that or use a third-party library for that, as this is not standard Cocoa Touch functionality). In my opinion, you'd need a pretty compelling business case to go down this road, though it can be done.
You could avoid email altogether, and develop a web service for letting the users send and receive messages. (This might make sense if the app is just sending messages between users of your app, for example.) Again, you'll have to contract with an ISP for web hosting, and you'll of course have to undertake the non-trivial exercise of writing your web service code. But this is architecturally cleaner than integrating with SMTP/IMAP/POP servers if the purpose of your app to facilitate communication between users of your app.
You haven't provided enough information for us to assess which approach best suits your situation.

Programmatically read email from inbox on iPhone

Is it possibleĀ for my iOS app to access the user's email inbox in the Mail app? I would like to be able to read the emails and save the attachments.
No. Apple doesn't provide an API for that.
However, you're free to ask the user for their mail server settings and then talk directly to an IMAP server, downloading the attachments yourself.
If you have presets for popular email providers (MobileMe, Gmail, Yahoo, etc.) this won't have to be too difficult for most users to deal with.

Resources