MFMailComposeViewController发送没有附件的电子邮件

时间:2013-04-15 19:14:22

标签: ios pdf mfmailcomposeviewcontroller

我在代码中制作了一个pdf文件,我将其作为电子邮件地址的附件发送。当它显示MFMailComposeController时,附件就在电子邮件中,但它没有附上我收到的电子邮件。可能的原因是什么?我在这里附上了代码。

    if(
       [MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailViewController=[[MFMailComposeViewController alloc]init];
        [mailViewController setSubject:@"Maintenance Request Form"];
        mailViewController.mailComposeDelegate=self;
            [mailViewController setToRecipients:[NSArray arrayWithObject:@"BRE@appiwork.com"]];


        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

        NSString *documentsDirectory = [paths objectAtIndex:0];

        NSString *file = [documentsDirectory stringByAppendingFormat:@"/MaintenanceRequest.pdf"];

        NSData *data=[NSData dataWithContentsOfFile:file];

        [mailViewController addAttachmentData:data mimeType:@"application/pdf" fileName:@"MaintenanceRequest.pdf"];

        [self presentViewController:mailViewController animated:YES completion:nil];

    }

0 个答案:

没有答案