首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >邮件中找不到电子名片附件

邮件中找不到电子名片附件
EN

Stack Overflow用户
提问于 2011-12-12 14:28:07
回答 1查看 759关注 0票数 1

我正试着用我的iphone发送一封电子邮件,附件是电子名片。当我发送邮件时,电子名片被附在邮件上。但是邮件的收件人找不到电子名片附件。需要帮助。这是我用过的代码

代码语言:javascript
运行
复制
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"Vcard" ofType:@"vcf"];
    NSData *myData = [NSData dataWithContentsOfFile:path];
    [picker addAttachmentData:myData mimeType:@"text/x-vcard" fileName:@"Vcard.vcf"];
    [picker setMessageBody:emailBody isHTML:NO];
    [self presentModalViewController:picker animated:YES];
    [picker release];

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-29 12:03:56

我找到了解决方案。我在苹果的雷达上提交了一个关于它的bug。MFMailcomposer有一个bug,你必须将图片和额外的附件一起发送,才能让像pdf这样的奇怪项目正常工作……试试这个,用你的卡替换pdf:

代码语言:javascript
运行
复制
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
NSString *emailSubject = [NSString localizedStringWithFormat:@"MedicalProfile"];
[controller setSubject:emailSubject];


NSString *fileName = [NSString stringWithFormat:@"%@.pdf", profileName];
NSString *saveDirectory = NSTemporaryDirectory();
NSString *saveFileName = fileName;
NSString *documentPath = [saveDirectory stringByAppendingPathComponent:saveFileName];  

*** YOU MUST INCLUDE AN IMAGE OR THE PDF ATTATCHMENT WILL FAIL!!!***
// Attach a PDF file to the email 
NSData *pdfData = [NSData dataWithContentsOfFile:documentPath];    
[controller addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName];


// Attach an image to the email
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"miniDoc" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
[controller addAttachmentData:imageData mimeType:@"image/png" fileName:@"doctor"];


[controller setMessageBody:[NSString stringWithFormat:@"%@'s Medical Profile attatched!", profileName] isHTML:NO];

[self presentModalViewController:controller animated:YES];
controller.mailComposeDelegate = self;
[controller release];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8470668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档