gpt4 book ai didi

iphone - 直接从应用程序将 mp3 文件附加到电子邮件?

转载 作者:行者123 更新时间:2023-11-28 22:38:55 29 4
gpt4 key购买 nike

我正在开发一个应用程序,如果用户选择一种声音,他们可以从该应用程序通过电子邮件将其发送给自己。

附件部分“似乎”有效,但是,当我发送电子邮件时,收件人没有附件?

在 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];

}

最佳答案

试试这个代码伙伴,

NSString *strFileName = [m_aryFileName objectAtIndex:nIndex];
strFileName = [strFileName stringByAppendingString:@".mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:strFileName];
NSData *nData = [[NSData alloc] initWithContentsOfURL:fileURL];

MFMailComposeViewController *pickerMail = [[MFMailComposeViewController alloc] init];
pickerMail.mailComposeDelegate = self;
[pickerMail setSubject:@"myMail Attachment"];
[pickerMail addAttachmentData:nData mimeType:@"audio/mpeg" fileName:strFileName ];
NSString *emailBody = @"Here is your attachment";
[pickerMail setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:pickerMail animated:YES];

关于iphone - 直接从应用程序将 mp3 文件附加到电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15112852/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com