2011-04-01 8 views
1

.doc 파일을 내 앱에서 프로그래밍 방식으로 이메일 첨부 파일로 보내려고합니다.iPad에서 첨부 파일로 doc 파일 보내기

+0

이 파일은 기존 .doc 파일입니까, 아니면 동적으로 생성 된 파일입니까? –

+0

내 응용 프로그램을 통해 동적으로 생성 오전 – Swastik

답변

6

mimeType이 "application/msword"인 - [MFMailComposeViewController addAttachmentData :]을 사용하십시오. 예 :

- (void)displayComposerSheet { 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

    [picker setSubject:@"I'm attaching a word document!"]; 

    // Set up recipients 
    NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
    NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
    NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

    [picker setToRecipients:toRecipients]; 
    [picker setCcRecipients:ccRecipients]; 
    [picker setBccRecipients:bccRecipients]; 

    // Attach a doc to the email 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"MyDocument" ofType:@"doc"]; 
    NSData *myData = [NSData dataWithContentsOfFile:path]; 
    [picker addAttachmentData:myData mimeType:@"application/msword" fileName:@"MyDocument"]; 

    // Fill out the email body text 
    NSString *emailBody = @"Please see the attached document."; 
    [picker setMessageBody:emailBody isHTML:NO]; 

    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 
} 
+0

나는이 코드를 사용하고 있습니다. 유일한 차이점은 .doc 파일을 문서 디렉토리에 저장하는 것입니다.이 메일 첨부 파일은 Mac에서는 열리지 만 ipad에서는 열 수 없음 – Swastik

+0

열기에 따라 열기를 의미합니까? doc 파일로 읽을 수 있거나 in을 열면 발견되어 앱 샌드 박스에 저장할 수 있습니까? –

관련 문제