Is there a way to pre-fill the fields of an email that is generated by selecting an automatically detected email address in a UITextView?
Asked
Active
Viewed 539 times
2
-
I'm pretty sure that the answer is that you can not do this... – lnafziger Mar 27 '12 at 03:08
-
Yes, I don't think so either, but I wanted to check. – Darren Mar 27 '12 at 03:12
2 Answers
2
I am successfully doing this by implementing the openURL: method. The link in the UITextView invokes the app delegate's openURL: method. There, I check to see if it's a mailto: URL, and if so, I instantiate the MFMailComposeViewController, which allows me to prepopulate the e-mail fields.
See this SO question for more information: How to intercept click on link in UITextView?
1
Yes. Take a look at the methods for MFMailComposeViewController:
– setSubject:
– setToRecipients:
– setCcRecipients:
– setBccRecipients:
– setMessageBody:isHTML:
– addAttachmentData:mimeType:fileName:
More info in the docs.

sosborn
- 14,676
- 2
- 42
- 46
-
I know how to fill the fields of an MFMailComposeViewController, but how do I get the instance created by selecting an email address in a UITextView? – Darren Mar 27 '12 at 02:51
-
I'm not sure I understand. You created an email earlier and you want access to it later. Is that right? – sosborn Mar 27 '12 at 02:55
-
No, I have a UITextView that gets filled with text, that includes an email address that is detected by the UITextView. When the user selects the email address an email window appears, with the To: field prefilled to the slected email address. I was wondering if there is a way to prefill the other fields of this email. – Darren Mar 27 '12 at 03:08
-
-
No problem, thanks anyway! I don't think it's actually possible, I just wanted to check. – Darren Mar 27 '12 at 12:00