Email with the iPhone
Im using this code to allow users to send an email through my application:
- (IBAction)sendEmail:(id)sender {
MFMailComposeViewController *mailComposer;
NSArray *emailAddresses;
emailAddresses=[[NSArray alloc]initWithObjects: email.text,nil];
mailComposer=[[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate=self;
[mailComposer setToRecipients:emailAddresses];
[self presentModalViewController:mailComposer animated:YES];
[emailAddres开发者_如何学Cses release];
[mailComposer release];
}
I was wondering, is there any way I can make it so that when users click the button, the To: field is already filled out?
Also, is it possible to validate the CC: field as well (e.g. checking for an @ sign etc.)?
Thanks, Anthony
The To: field is set using this code:
[mailComposer setToRecipients:emailAddresses];
Basic validation is done for you
If you want to do additional validation, then prompt for the To/CC/BCC fields before you show the MFMailComposeViewController, and do the validation as part of the UITextField input.
精彩评论