iOS:发送带附件的电子邮件会自动添加另一个附加 (.txt) 文件
我使用以下代码发送包含 NSData 对象内容的电子邮件(变量名称:data):
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setSubject:@"Subject"];
[controller addAttachmentData:data mimeType:@"application/pdf" fileName:@"Attachment"];
[controller setMessageBody:@"Please find attached the connections for..." isHTML:NO];
controller.mailComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
它将生成的 UIView 添加为 pdf 作为附件并发送电子邮件。一切都很好,除了一个问题:
收到电子邮件时,连同所附的 pdf 一起,还有另一个附加的 .txt 文件,其内容是:“从我的 iPad 发送”。如果我不附加 pdf 文件,“从我的 iPad 发送”消息将出现在电子邮件正文中,而不是附加文件中。
有谁知道如何解决这个问题?我不希望在消息中附加文本文件。
问候,
佩塔尔
I am using the following code to send an email with the contents of NSData object(with the variable name: data):
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setSubject:@"Subject"];
[controller addAttachmentData:data mimeType:@"application/pdf" fileName:@"Attachment"];
[controller setMessageBody:@"Please find attached the connections for..." isHTML:NO];
controller.mailComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
It adds a UIView generated as a pdf as an attachment and sends the email. It is all good, besides a single problem:
When the email is received, along with the attached pdf, there is another attached .txt file whose contents are: "Sent from my iPad" . If I do not attach the pdf, the "Sent from my iPad" message appears in the body of the email, instead in an attached file.
Does anyone have a clue how this can be resolved ? I do not want the text file to be attached in the message.
Regards,
Petar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎当您发送带有附件的电子邮件时,其中的所有内容都被包装为多部分/混合消息,并且所有内容都编码为 Base64,包括消息正文和签名!所以它看起来像这样...
(即
“Hi Mom!”
编码为Base64)snip
(即
从我的 iPad 发送
作为 Base64)
即使您转到“设置>>”邮件、联系人、日历并删除签名,您仍然会附加一个空的 HTML 文档。
正确的长期答案可能是将其作为错误提交给苹果并等待。同时,如果这确实是一个严重的错误,我建议您自己生成整个多部分/混合电子邮件正文,而不带签名,并看看这是否会欺骗 MFMailComposeViewController 认为该电子邮件没有附件。就我个人而言,我想我只会告诉我的客户接受它。 :)
It seems that when you send an email with an attachment, everything in it is wrapped up as a multipart/mixed message, and everything encoded as Base64, including the message body and the signature! So it looks like this...
(that's
"Hi Mom!"
encoded as Base64)snip
(that's
<html><body bgcolor="#FFFFFF"><div></div><div><br><br>Sent from my iPad</div></body></html>
as Base64)
Even if you go to Settings >> Mail, Contacts, Calendars and erase the signature, you still get an empty HTML document attached.
The right long-term answer will probably be to submit this to Apple as a bug and wait. In the meantime, if this is really a showstopper bug, I'd suggest that you generate the entire multipart/mixed email body yourself, without the signature, and see if that fools MFMailComposeViewController into thinking that the email doesn't have an attachment. Personally, I think I'm just going to tell my customer to live with it. :)