如何从UITextfield获取价值并将其发送到电子邮件?

Dan*_*any 3 iphone xcode uitextfield ios

我创建了一个包含表单的应用程序,必须填写适当的文本字段..现在我需要在textfield中获取所有数据并将其发送到email.here我的代码用于撰写电子邮件

- (IBAction)compose:(id)sender 
{
if (text1.text=@"" && text2.text=@"" && text3.text=@"" && text4.text=@"" && text5.text=@"") {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                                                    message:@"Please enter all the field details" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles: nil];
}
                                                                             else{


if ([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

    mailer.mailComposeDelegate = self;

    [mailer setSubject:[NSString stringWithFormat:@"Appointment From Mr/Mrs. %@",text1.text]];

    NSArray *toRecipients = [NSArray arrayWithObjects:@"xxx@xxxx.com", nil];
    [mailer setToRecipients:toRecipients];



    NSString *emailBody =[NSString stringWithFormat:@"Name =%@\nDate= %@\nPreferred Time Slot= %@\nE-Mail=%@\nSpecific Requests=",text1.text,text2.text,text3.text,text4.text,text5.text]; 
    [mailer setMessageBody:emailBody isHTML:NO];


    [self presentModalViewController:mailer animated:YES];

    [mailer release];
}
else
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                                                    message:@"Your device doesn't support the composer sheet" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles: nil];
    [alert show];
    [alert release];
}
}
Run Code Online (Sandbox Code Playgroud)

}

如果所有文本字段都为null,则必须弹出警报.但是我收到错误了?...引导我请...

Oma*_*ith 12

如果您想知道如何从文本字段中获取文本并发送它,则需要使用textfield.text

NSString *emailBody = textField.text;
[mailer setMessageBody:emailBody isHTML:NO];
Run Code Online (Sandbox Code Playgroud)