• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - 在 iOS 中使用电子邮件 uri 方案的附件

[复制链接]
菜鸟教程小白 发表于 2022-12-13 10:39:23 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在实现一个 iphone 应用程序 (iOS 4.2),我想从该应用程序触发电子邮件客户端发送带有附件的消息。我可以有效地结合使用 uri 方案和类 NSURL 来触发电子邮件应用程序,但我想知道是否可以附加图像。我曾尝试使用 mailto:[email protected]?subject=sthg&body=sthgelse&attachment=/path/to/file 但附件不包括在内。我知道 iphone 应用程序是沙盒的,因此电子邮件实用程序可能无法访问我的图像的路径,因为它位于我的应用程序包中。另一方面,我正在考虑使用照片管理器管理我的图像。 (1)有没有办法以这种方式包含附件? (2) 如果是这样,是否可以从我的应用程序或照片客户端引用图像?我在 mailto RFC 中找不到任何附件参数,但也许 Apple 提供了一些方法来实现这一点。

提前感谢您的帮助,

路易斯



Best Answer-推荐答案


MFMailComposeViewController 将能够做到这一点,下面的一些使用示例: 记得添加 MessageUI.framework

MFMailComposeViewController *email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;
[email setSubject"Whatever"];

// Set up recipients
NSArray recipients = [NSArray arrayWithObject"[email protected]"]; 

[email setToRecipients:recipients];


// Attach an image to the email
UIImage *attachment = ...;
NSData *data = UIImagePNGRepresentation(attachment);
[email addAttachmentData:myData mimeType"image/png" fileName"ok.png"];

// Fill out the email body text
NSString *emailBody = @"test mail";
[email setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];

[email release];

关于iphone - 在 iOS 中使用电子邮件 uri 方案的附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8833916/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap