gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 06:18:49 28 4
gpt4 key购买 nike

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

- (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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com