0

録音したサウンドファイルをMFMailComposeViewControllerの添付ファイルとして送信しようとしています。

サウンドファイルはOKです。

ピッカーは正しいファイル名を表示し、オーディオファイルアイコンを添付ファイルとして表示し、メールを送信しますが、結果に添付ファイルがありません。

送信メールの送信元の下に添付しました。「Content-Disposition:attachment;」の代わりに「text/plain」コンテンツタイプの部分があります。予想通り。

これは、パスを定義してオーディオファイルを添付するための私のコードコードです。何が間違っている可能性がありますか?

#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--
4

1 に答える 1

0

[url path]が正しくないことがわかりました。代わりdataWithContentsOfFileに使用しましたが、正常に動作します。[[self.recorder url] path]

于 2010-04-12T14:54:09.467 に答える