我正在开发一个应用程序,如果用户选择一种声音,他们可以从应用程序通过电子邮件将其发送给自己。
附件部分“似乎”可以工作,但是,当我发送电子邮件时,收件人没有附件?
在 iPad/iPhone 本身上,它看起来像是在撰写时附加了它,但它不起作用?:/
这是我正在使用的代码;
- (void)onSend:(id)sender{
int nIndex;
UIButton *btnSender = (UIButton *)sender;
NSLog( @"%d", btnSender.tag );
for ( int i = 0; i < [ m_aryFileName count ]; i++ ) {
if( i == ( btnSender.tag - 100 ) ){
nIndex = i;
}
}
NSString *strFileName = [ m_aryFileName objectAtIndex:nIndex ];
strFileName = [ strFileName stringByAppendingString:@".mp3" ];
NSData* nData = [ NSData dataWithContentsOfFile:strFileName ];
MFMailComposeViewController *pickerMail = [[MFMailComposeViewController alloc] init];
pickerMail.mailComposeDelegate = self;
[pickerMail setSubject:@"myMail Attachment"];
// Attach an image to the email
[pickerMail addAttachmentData:nData mimeType:@"audio/mp3" fileName:strFileName ];
// Fill out the email body text
NSString *emailBody = @"Here is your attachment";
[pickerMail setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:pickerMail animated:YES];
[pickerMail release];
}