在iPad上将文档文件作为附件发送 [英] sending doc file as an attachment on iPad
本文介绍了在iPad上将文档文件作为附件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以编程方式从我的应用程序发送.doc文件作为电子邮件附件.
I want to send .doc file as an email attachment from my app programmatically.
推荐答案
使用mimeType为"application/msword"的-[MFMailComposeViewController addAttachmentData:].例如:
Use -[MFMailComposeViewController addAttachmentData:] with a mimeType of "application/msword". For example:
- (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:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];
[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];
}
这篇关于在iPad上将文档文件作为附件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文