从 iPhone 设置获取邮件

发布于 2024-12-28 14:07:19 字数 122 浏览 0 评论 0原文

有什么方法可以在 iPhone 设置中创建我的个人电子邮件帐户吗?

我正在制作一个发送邮件的应用程序,并且想要选择我在 iPhone 上拥有的电子邮件帐户之一来发送,然后选择我的议程的目的地。

谢谢

there any way to get my personal email accounts created in the iphone settings ??

I am making an application to send mail and would like to select one of the email accounts I have on my iPhone to send and then select the destianatorios of my agenda.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疑心病 2025-01-04 14:07:19

我不太确定你想要做什么,但 iOS 提供了多种显示电子邮件撰写视图控制器的方法,以及访问用户保存在他/她的 iDevice 上的联系人的方法。

要显示邮件撰写视图,请在项目中创建一个到 MessageUI.framework 的弱链接(最好使用弱链接,因为 MessageUI.framework 在非常旧的版本上不可用iOS 版本),然后执行如下操作:

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil) {
    // MessageUI Library is available. Presenting modal mail composer view.
    MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    [mailViewController setSubject:@"This is the subject of the email"];
    [mailViewController setMessageBody:@"This is the body of the email." isHTML:NO];
    [self presentModalViewController:mailViewController animated:YES];
    [mailViewController release];
} else {
    // MessageUI Library not available. Opening mail.app using a URL scheme.
    //  Note that this URL scheme only works on iOS3 and below, and seems to only accept a 
    //  limited number of characters. For this reason, we only attach the URL.
    NSString *mailBody = @"This is the body of the email."
    NSString *mailSchemeURL = [NSString stringWithFormat:@"mailto:?body=%@", mailBody];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[mailSchemeURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}

如果您想访问 iDevice 上的联系人,请将 AddressBook.framework 链接到您的项目中。您可以按照 Apple 的编程指南。例如,您可以获取所有联系人的数组,如下所示:

ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *contacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

我希望您可以通过使用上述组合来实例化具有特定联系人的邮件撰写视图。希望这有帮助!

I'm not exactly sure what you're trying to do, but iOS offers several ways to display an email composition view controller, as well as methods to access the contacts a user has saved on his /her iDevice.

To display a mail composition view, make a weak link to the MessageUI.framework in your project (a weak link is preferred since the MessageUI.framework is not available on very old iOS versions), then do something like this:

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil) {
    // MessageUI Library is available. Presenting modal mail composer view.
    MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    [mailViewController setSubject:@"This is the subject of the email"];
    [mailViewController setMessageBody:@"This is the body of the email." isHTML:NO];
    [self presentModalViewController:mailViewController animated:YES];
    [mailViewController release];
} else {
    // MessageUI Library not available. Opening mail.app using a URL scheme.
    //  Note that this URL scheme only works on iOS3 and below, and seems to only accept a 
    //  limited number of characters. For this reason, we only attach the URL.
    NSString *mailBody = @"This is the body of the email."
    NSString *mailSchemeURL = [NSString stringWithFormat:@"mailto:?body=%@", mailBody];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[mailSchemeURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}

If you want to access contacts on the iDevice, link AddressBook.framework into your project. You can access the values on the device by following the instructions in Apple's programming guide. For example, you can get an array of all contacts like so:

ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *contacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

I expect you can instantiate a mail composition view with a specific contact by using a combination of the above. Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文