2009-09-07 30 views
9

私はMessageUIフレームワークを使用して、添付ファイル付きメールを自分のアプリケーションから送信しました。 しかし、私は次のエラーを得た、iphone電子メールの添付ファイル

2009-09-07 19:52:23.483 emailTest[11711:5b17] 
Error loading /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator: dlopen(/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator, 265): Library not loaded: /System/Library/PrivateFrameworks/MobileWirelessSync.framework/MobileWirelessSync 

Referenced from: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator 

     Reason: image not found 

2009-09-07 19:52:23.489 emailTest[11711:5b17] [+[AccountsManager _migrateAccountsIfNeeded]] Accounts migration failed 
[Switching to process 11711 local thread 0xf03] 

私のコードは、私を助けてください、

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init]; 
picker.mailComposeDelegate = self; 
[picker setSubject:@"This is iPhone email attachment test"]; 

UIImage *sampleImg = [UIImage imageNamed:@"iPhone.jpg"]; 
NSData *imageData = UIImageJPEGRepresentation(sampleImg, 1); 
[picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"iPhone.jpg"]; 


NSString *emailBody = @"I am sending the image attachment with iPhone email service"; 
[picker setMessageBody:emailBody isHTML:YES]; 

[self presentModalViewController:picker animated:YES]; 
[picker release]; 

です。

+0

具体的には、添付ファイルを作成するためにどのようなコードを実行していますか?メッセージを切り離すには?どのくらい正確に「MessageUIフレームワークを使用していますか? – Tim

+0

コードをご覧ください。 – SST

+0

こんにちは、 あなたのコードはうまくいきましたか? 電子メールの送信ボタンに触れている間も同じメッセージが表示されます。しかし、私はメールに添付ファイルを追加していません。 キャンセルボタンを押したときにメールコントローラを閉じることができませんでした。私はcocos2d層にメールコントローラを追加しています。助けてください。 ありがとうございます。 –

答えて

16

ファイル名に拡張子を入力する必要はありません。 「iphone.jpg」のようなものは動作しません。あなたは既にmimeTypeを定義しているので、単に "iphone"をfilenameに書きます。また、リソースのパスを定義する必要があります。

"rainy.png"ファイルをメールに添付するサンプルコードを以下に示します。

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
picker.mailComposeDelegate = self; 

[picker setSubject:@"Hello"]; 


// Set up recipients 
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

[picker setToRecipients:toRecipients]; 
[picker setCcRecipients:ccRecipients]; 
[picker setBccRecipients:bccRecipients]; 

// Attach an image to the email 
NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"png"]; 
NSData *myData = [NSData dataWithContentsOfFile:path]; 
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"rainy"]; 

// Fill out the email body text 
NSString *emailBody = @"It is raining"; 
[picker setMessageBody:emailBody isHTML:NO]; 

[self presentModalViewController:picker animated:YES]; 
[picker release]; 
0

このエラーは、あなたのコードではなく、実行中のメールインテルのシミュレータに関連しているようです。でも株式AppleのサンプルMailComposerは、シミュレータで同じエラーを報告:

2009-11-12 20:30:39.270 MailComposer[7426:4f1f] Error loading /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator: dlopen(/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator, 265): Library not loaded: /System/Library/PrivateFrameworks/MobileWirelessSync.framework/MobileWirelessSync 
    Referenced from: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/DataClassMigrators/AccountMigrator.migrator/AccountMigrator 
    Reason: image not found 
2009-11-12 20:30:39.271 MailComposer[7426:4f1f] [+[AccountsManager _migrateAccountsIfNeeded]] Accounts migration failed 
+0

こんにちは、 私は同じログになっています。私がメールコントローラのクローズボタンまたは送信ボタンに触れたとき。私はcocos2d層にメールコントローラを追加しています。 私は「シミュレータではなくコードに実行しているメールを実行しています」ということはありません。それは何ですか ?私たちはそれを変更できますか? ありがとうございます。 –

0

はMFMailComposeViewControllerを却下するには、次のメソッドを追加します。IOS 4,5でテストメールに画像を添付ため

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult: (MFailComposeResult)result error:(NSError*)error 

{ 
// NEVER REACHES THIS PLACE 
[self dismissModalViewControllerAnimated:YES]; 

NSLog (@"mail finished"); 
} 
+0

良い点ですが、これはおそらくここでは問題ではありません... btwは、 'MFailComposeResult'の代わりに' MFMailComposeResult'でなければなりません。 – newenglander

0

使用この、 6

MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 
    UIImage *myImage = [UIImage imageNamed:@"image.png"]; 
    NSData *imageData = UIImagePNGRepresentation(myImage); 
    [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"image"]; 
関連する問題