开发者

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

Email with the iPhone


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜