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.
Your default email account is simply your primary email account. The email will appear when you tap the “compose” email icon.
Open the email app on your phone. Select your email provider from those listed (Gmail, Yahoo, Hotmail/Outlook, etc) or the “Other” option. Email services from website hosts or businesses will generally be “Other.” Enter your email account information as directed on the screen.
In Settings, click “Apps.” In Apps, click “Default Apps” in the sidebar. In the Default Apps section, click the icon located just below “Email.” This will allow you to select a new email client that you'd like to use as default.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With