access default email address - iphone

I am using the MFMailComposeViewController in 3.0 to send an email with attachment etc. inside my app. I would like the "To:" address to be defaulted to the default account/address on the device. How can I access this address to place it into a string for the setToRecipients?
Essentially, I'm going to let the user send an email to themselves (as the default "To") with an attachment inside the app.

The API doesn't expose that information publicly (for probably good reasons, such as preventing developers from harvesting iPhone users' email addresses).
You should probably go about asking for the user's email address and then saving it for future use.

It appears that the accepted answer is wrong
Getting user's default email address in Cocoa
This answer shows the code for getting the e-mail address from the address book ( listed under 'me' )
EDIT: Note the comment! OSX only not iOS :|

You can use ABGetMe for iOS to get the user's address book card. Have a look at the source code, you will see how to retrieve all e-mail addresses for a given ABRecordRef.

Related

how to find the IP address of an email recipient

I'm wondering if it's possible, through perhaps pixel tracking or another means, to know an email recipient's IP address to provide location-based dynamic content?
The most reliable way would likely be to embed a tiny image in the header that links to one of your servers. Then when the open the image you can get their ip address based on where it was accessed.
Pixel tracking is easy,
but you mentioned "dynamic content".
This means you need to make your email content change after the recipients open their email, which can only be achieved by javascript.
As far as I know, some email clients will block javascript execution, see here.
If you can use the first mail to record user's ip address, and store in database, you can use the information in the second mail.
Or you can provide a link in your email content, which leads the user to a dynamic webpage.
#Aviator provided a nice solution of generating dynamic image to solve the problem.

How to check whether an email has been used in a website?

Suppose I have an email address abcd1234#gmail.com, I would like to check whether this email address has been used in Apple,Facebook,Twitter and so on. (used means it has been registered as an account).
How to do it with programming? It there any open API ? Any language will be fine.
No. A feature like this would be a security risk, because finding valid account email addresses is the first step in getting control over the account (second step is retrieving the password from somewhere).
There is no such api, this seems to be really unsecure thing.
The way I can see for you to do this – try to register a new account with this e-mail address, and view the result.

iOS access recent emails

I know this is likely to be answered "sorry buddy", but is there a way i can access my recently sent emails from another iOS app? I really don't need the contents of the emails just the addresses. Basically if you haven't stored the contact information in your address book, I still want to be able to pull those addresses.
For example in the email app, when you compose a new email, as you start typing in an email address it will try to autofill with recently sent/received email addresses. I'm trying to mimic this behavior.
Point me in the right direction if there is already a stack overflow question about this.
No, there is not API that will allow this.
Apps can't acces other apps data since they are sandboxed.
Given the quick answers I received confirming my suspicion that this can't be done, I'm thinking I will just provide a way people can set up email accounts the way the built-in mail app does it. By that I mean I will allow people to select from the major web-based mail providers like gmail, yahoo mail, .. then also allow them to create a mail account with their mail server (address, username, password, port, etc.)
It's kind of overkill since I just want their recently used email addresses, and will scare off people who don't want to give access to their personal mail, but if its all i can do then so be it.

Can we get the From email address that is set in MFMailComposeViewController?

I am able to get Recipient email address from the MFMailComposeViewController using http://jomnius.blogspot.com/2011/02/how-to-find-mfmailcomposeviewcontroller.html link.
But I want From email Address. So is their any way to get From email Address...
Any links related to this is also welcome...
thanks..
I assume you want to fetch User's Configured email address in iPhone. If so, You can't fetch email configuration of iOS devices due to privacy issues.

how to add sender into an HTML coded email?

I need to send an email from my iPhone app but the name of the sender needs to be included within the body.
I do not know how to do that.
If you're using MFMailComposeViewController it takes the user's 'default' email account (as set up in Settings) and the email is sent from there. AFAIK, there's no way to obtain that email address (and the name that goes with it) programmatically.
But if your app can somehow get the user to associate their sender email account (via an addressbook picker) then you could use the standard AddressBook APIs to get the sender name and then insert that into the message.
[ It's not clear from your question if you're having problems with sending email, getting user names from contacts, or compositing HTML messages. Perhaps if you edited your question and explained what you're trying to do and what you've tried you'll get a better answer. ]