gpt4 book ai didi

objective-c - 如何在 iPhone 中填写电子邮件的“收件人”和“主题”?

转载 作者:行者123 更新时间:2023-11-29 04:56:08 27 4
gpt4 key购买 nike

我的应用程序中有一个名为“联系我们”的按钮!有没有办法在 iPhone 中打开 Eamil 客户端,并填写我提供的“收件人”和“主题”?

最佳答案

您将需要使用 MFMailComposeViewController类(class)。以下是 Apple 的 MailComposer example 的相关部分:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@"Hello from California!"];

// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
[picker setToRecipients:toRecipients];

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

MailComposer 示例还向您展示了如何打开外部邮件应用程序:

NSString *recipients = @"mailto:first@example.com&subject=Hello from California!";
NSString *body = @"&body=It is raining in sunny California!";

NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];

关于objective-c - 如何在 iPhone 中填写电子邮件的“收件人”和“主题”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7920655/

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