通过iPhone发送的邮件中没有附件
我正在尝试使用MFMailComposeViewController将录制的声音文件作为附件发送 声音文件正常 选择器显示正确的文件名,将音频文件图标显示为附件,发送邮件,但结果中没有附件 我在下面附上了发送邮件的来源。有一个文本/普通内容类型部分,而不是内容配置:附件;正如所料 这是我定义路径和附加音频文件的代码。有什么不对劲吗通过iPhone发送的邮件中没有附件,iphone,email,attachment,mfmailcomposeviewcontroller,Iphone,Email,Attachment,Mfmailcomposeviewcontroller,我正在尝试使用MFMailComposeViewController将录制的声音文件作为附件发送 声音文件正常 选择器显示正确的文件名,将音频文件图标显示为附件,发送邮件,但结果中没有附件 我在下面附上了发送邮件的来源。有一个文本/普通内容类型部分,而不是内容配置:附件;正如所料 这是我定义路径和附加音频文件的代码。有什么不对劲吗 #define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Docume
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
#define FILEPATH [DOCUMENTS_FOLDER stringByAppendingPathComponent:[self dateString]]
以及发送邮件的来源:
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路径]对于dataWithContentsOfFile是不正确的,我使用了[[self.recorder url]路径]来代替它,它工作得很好
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--