How to customize MFMailComposeViewController so that i can make the "to" field as non-editable?

Rajkanth picture Rajkanth · Feb 19, 2011 · Viewed 7.8k times · Source

I am using MFMailComposeViewController for sending feedback in my app. It works fine. But the problem here is, the user can edit/delete the "to" address. I want to make it as a non-editable one. May be, the user can add some mail addresses in "to" field.

But he/she should not delete the feedback address (Here, it is "[email protected]").

Here is my code...

MFMailComposeViewController *composeWindow = [[MFMailComposeViewController alloc] init];
composeWindow.mailComposeDelegate = self;

NSString *str = @"Subject of the feedback";
[composeWindow setSubject:[str stringByAppendingString:[[UIDevice currentDevice]systemVersion]]];

NSArray *toRecipients = [NSArray arrayWithObject: @"[email protected]"]; 
[composeWindow setToRecipients:toRecipients];

[self presentModalViewController:composeWindow animated:YES];
[composeWindow release];

Thanks in Advance

Rajkanth

Answer

Massimo Cafaro picture Massimo Cafaro · Feb 19, 2011

You can not customize MFMailComposeViewController to avoid editing. Apple forbids this, and the reason is quite simple: it is the user and not you that must decide exactly what to send, to whom etc. The same applies for the UI controller allowing to send SMS (text) messages. And, of course, Apple does not allows sending an email or SMS without explicit interaction with the user. It is the user that must validate and send the email or SMS message. The validation process include the ability to cancel the message or to change any single property at will, including the "to" recipients.