Search code examples
iosemailsubclassing

is there a way to change the body of the email programatically before "Send" in MFMailComposeViewController?


Currently I am displaying a MFMCVC with a preset body containing a link in it. I would like to "fiddle" with the body of the message after the user has chosen the "To:" recipients and just before the "Send" is taking place. I would like to change the URL in the body and put the "To:" value instead of a placeholder I have in the URL.

I studied the headers of MFMCVC but can't find a "sendMail" action anywhere so that I could subclass MFMCVC. Hmm would it be possible to create my own target for the Send button, fetch the existing target, change it in my method and then call what was originally there ? If yes... how could I implement it ?


Solution

  • From the documentation

    Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.

    So, if you're hoping to submit to the app store, you can't do this. You'd have to have your own interface to choose the recipients, and build your message body before presenting the composer.