iPhone 应用内电子邮件
我的应用程序发送电子邮件,但有没有办法将照片放在我的电子邮件中我发送的文本上方。有点像显示我的徽标的标题。
I have my application sending an email, but is there a way to put a photo in my email above the text i'm sending. Kind of like a header to display my logo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您使用 MFMailComposeViewController 附加图像时,它始终显示在消息底部(在文本下方,但在签名上方),并且在当前版本的框架中无法更改。
但是,可以将图像数据编码为 base64 并将其直接放置在应用程序的 HTML 正文中。我不会在此处包含代码(您可以轻松地通过谷歌搜索),因为这很棘手且有问题,因为并非所有读者都会正确解释这一点。
如果这是所有电子邮件都相同的标题图像,您可以将其放在服务器上的某个位置,然后在引用该文件的 HTML 电子邮件正文中包含
标记。
如果这是动态图像,您可以让您的应用将其上传到众多图像托管站点之一,检索 URL 并再次将其包含为
的
src
。 HTML 电子邮件正文中的 code> 标记。When you attach an image using the MFMailComposeViewController it is always displayed at the bottom of the message (under your text, but above the signature) and this cannot be changed in the current version of the framework.
It is possible, however, to encode your image data into base64 and place this directly in the HTML body of your app. I won't include the code here (you can easily google it) because this is tricky and problematic since not all readers will interpret this correctly.
If this is a header image that will be the same for all emails you can put this on a server somewhere and then include an
<img>
tag in your HTML email body that references this file.If this is a dynamic image you can have your app upload it to one of the many image hosting sites, retrieve the url and again include it as the
src
of an<img>
tag in your HTML email body.您应该使用 MFMailComposeViewController 类中的 - (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename 方法。
这是 这方面的一个很好的例子,它展示了从相机中拍摄图像,然后向其发送电子邮件!
You should use the
- (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
method from the MFMailComposeViewController class.Here's a great example of this that shows taking an image from the camera and then sending it an an email message!