作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我创建了一个应用程序,其中包含表单并且必须在适当的文本字段中填写..现在我需要在文本字段中获取所有数据并将其发送到电子邮件中。这是我编写电子邮件的代码
- (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];
}
}
如果所有文本字段都为空,则它必须弹出警报。但是我收到错误消息?...请指导我...
最佳答案
如果您想知道如何从文本字段中获取文本并发送它,您将需要使用 textfield.text
NSString *emailBody = textField.text;
[mailer setMessageBody:emailBody isHTML:NO];
关于iphone - 如何从 UITextfield 获取值并将其发送到电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11205750/
我是一名优秀的程序员,十分优秀!