如何在电子邮件IOS中设置收件人

时间:2013-04-08 12:53:53

标签: ios email

这是我点击

时用于邮寄的内容
- (IBAction)email:(id)sender {
    if ([MFMailComposeViewController canSendMail]) {

        MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
        mailViewController.mailComposeDelegate = self;
        [mailViewController setSubject:@"Subject Goes Here."];

         [mailViewController setMessageBody:@"Your message goes here." isHTML:NO];

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


          }

          else {

              NSLog(@"Device is unable to send email in its current state.");

          }

现在当我点击它时有邮件按钮然后该视图出现在撰写邮件中 所以旁边的按钮有一个名为_emailTextField的文本字段,所以我想要的是当点击按钮时文本字段应该出现在撰写邮件视图中,就好像在textfield中有hell@yahoo.com然后在mailview中它应该是地狱@yahoo作为收件人

请告诉我该怎么做?

3 个答案:

答案 0 :(得分:3)

  NSArray *recipentsArray = [[NSArray alloc]initWithObjects:@"xxx@gmail.com", nil];
 [mailViewController setToRecipients:recipentsArray];

答案 1 :(得分:1)

您可以使用:

[mailViewController setToRecipients:[NSArray arrayWithObject: _emailTextField.text,nil]];

希望这会对你有所帮助。

一切顺利!!!

答案 2 :(得分:0)

mailViewController.recipients = [NSArray arrayWithObjects:@"abc@xyz.com",nil];