【问题标题】:Can't find vcard attachment with the mail邮件中找不到电子名片附件
【发布时间】:2011-12-12 06:28:06
【问题描述】:

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

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];

谢谢

【问题讨论】:

    标签: iphone ios vcf-vcard email-attachments mfmailcomposer


    【解决方案1】:

    我找到了解决方案...我在 Apple 雷达上提交了一个关于它的错误。 MFMailcomposer 有一个错误,您必须将图像连同额外的附件一起发送,才能使 pdf 之类的奇怪项目正常工作...试试这个并用您的卡替换 pdf:

    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];
    

    【讨论】:

      猜你喜欢
      • 2016-07-30
      • 2014-06-06
      • 1970-01-01
      • 2015-05-28
      • 1970-01-01
      • 2016-04-25
      • 1970-01-01
      • 2019-10-13
      • 2011-09-03
      相关资源
      最近更新 更多