我想以編程方式從我的應用發送.doc文件作爲電子郵件附件。在iPad上發送doc文件作爲附件
1
A
回答
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 2011-04-01 06:45:06
+0
通過打開,您的意思是打開並且可以作爲doc文件讀取,或者在檢測到時打開並保存到應用程序沙箱中? – 2011-04-01 21:50:39
相關問題
- 1. 發送.doc文件作爲郵件的附件
- 2. 通過電子郵件發送Google Doc作爲PDF附件
- 3. 發送壓縮文件作爲附件
- 4. 作爲附件發送多個文件
- 5. 將上傳的文件作爲電子郵件附件發送
- 6. 無法找到文件作爲附件發送文件在python
- 7. 發送Word文檔作爲附件
- 8. 發送已上傳的文件作爲附件
- 9. 如何在android中發送csv文件作爲附件?
- 10. 作爲附件發送文件在目標c
- 11. 如何在BlackBerry中發送音頻文件作爲附件?
- 12. Powershell發送文件作爲郵件的附件
- 13. 保存文件並作爲電子郵件附件發送
- 14. 將文件作爲電子郵件附件發送後,文件卡在w3wp.exe中
- 15. 如何使用附件(.doc文件)發送電子郵件使用php
- 16. cakephp - 保存文件syncronized並作爲附件發送
- 17. 發送一個xml文件作爲附件與Android
- 18. 發送xlsx格式的文件作爲附件使用TSQL
- 19. 發送一個HTML文件作爲附件
- 20. 將文件作爲附件發送到瀏覽器
- 21. Play Framework:作爲附件發送CSV文件
- 22. Excel作爲附件發送文件的緩存版本
- 23. 是否可以將文件作爲iMessage附件發送?
- 24. 通過短信發送附件作爲附件
- 25. 發送郵件在PHP與HTML頁面附加作爲文本
- 26. 在PHP中發送多個word文檔作爲附件
- 27. 發送一個zip文件作爲附件在ios中的JSON發佈請求?
- 28. PHP:如何發送文件作爲附件,無需上傳到服務器?
- 29. PHP:發送帶有上傳圖片的文本郵件作爲附件
- 30. 在運行時生成HTML文件並作爲電子郵件附件發送
這是一個預先存在的.doc文件,還是一個動態生成的文件? – 2011-04-01 05:52:28
我通過我的應用程序動態創建它 – Swastik 2011-04-01 06:41:18