[英]There is no attachment in the sent mail by iPhone
我正在嘗試將錄制的聲音文件作為附件發送到MFMailComposeViewController。
聲音文件正常。
選擇器顯示正確的文件名,將音頻文件圖標顯示為附件,發送郵件,但結果中沒有附件。
我附在發送郵件的來源下面。 有一個“文本/純文本”內容類型部分,而不是“ Content-Disposition:附件;” 如預期的那樣。
這是我的代碼,用於定義路徑並附加音頻文件。 有什么事嗎
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
#define FILEPATH [DOCUMENTS_FOLDER stringByAppendingPathComponent:[self dateString]]
...
NSURL *url = [NSURL fileURLWithPath:FILEPATH];
self.recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
...
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSURL *url = [NSURL fileURLWithPath: [NSString stringWithFormat:@"%@", [self.recorder url]]];
NSData *audioData = [NSData dataWithContentsOfFile:[url path]];
[picker addAttachmentData:audioData mimeType:@"audio/wav" fileName:[[url path] lastPathComponent]];
以及發送郵件的來源:
Content-type: multipart/mixed; boundary=Apple-Mail-1-614960740
Content-transfer-encoding: 7bit
MIME-version: 1.0 (iPod Mail 7E18)
Subject: Sound message:
Date: Sun, 11 Apr 2010 11:58:56 +0200
X-Mailer: iPod Mail (7E18)
--Apple-Mail-1-614960740
Content-Type: text/plain;
charset=us-ascii;
format=flowed
Content-Transfer-Encoding: 7bit
It is a text here
--Apple-Mail-1-614960740
Content-Type: text/plain;
charset=us-ascii;
format=flowed
Content-Transfer-Encoding: 7bit
Sent from my iPod
--Apple-Mail-1-614960740--
我發現[url path]
不適合dataWithContentsOfFile
,我改用[[self.recorder url] path]
可以正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.