2009-09-07 14 views
9

Użyłem MessageUI ramach, aby wysłać wiadomość z załącznikiem z mojej aplikacji. ale mam następujący błąd,iPhone załącznik e-mail

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] 

mój kod jest

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

proszę mi pomóc.

+0

Bardziej szczegółowo - z jakiego kodu korzystasz podczas tworzenia załącznika? Aby odłączyć wiadomość? Jak dokładnie "korzystasz z frameworka MessageUI"? – Tim

+0

proszę spojrzeć na kod. – SST

+0

cześć, czy twój kod zadziałał. Ja też otrzymałem tę samą wiadomość, gdy dotknąłem przycisku Wyślij w e-mailu. Ale nie dodaję żadnych załączników z pocztą. Nie mogłem zwolnić kontrolera poczty po dotknięciu przycisku Anuluj. Dodaję kontroler poczty do warstwy cocos2d. Proszę o pomoc. Dziękuję. –

Odpowiedz

16

Nie musisz wpisywać rozszerzenia w nazwie pliku. jak "iphone.jpg" nie działa. po prostu napisz "iphone" w nazwie pliku, ponieważ już zdefiniowałeś mimeType. Musisz także zdefiniować ścieżkę dla zasobu.

Poniżej znajduje się przykładowy kod dołączający plik "rainy.png" do wiadomości e-mail.

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

Błąd ten wydaje się być związane z systemem pocztowym int on symulatorze, a nie w kodzie. Próbka nawet magazynie Apple MailComposer zgłasza identyczny błąd w symulatorze:

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

Witam, Otrzymuję to samo w dzienniku. Kiedy dotknąłem przycisku zamykania lub wysyłania w kontrolerze pocztowym. Dodaję kontroler poczty do warstwy cocos2d. I nie otrzymuję "działającej poczty w symulatorze, a nie w twoim kodzie". Co to jest ? możemy to zmienić? Dziękuję. –

0

Dodaj następujący sposób oddalić MFMailComposeViewController:

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

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

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

Dobra sprawa, ale to chyba nie jest problem ... btw, powinno być 'MFMailComposeResult' zamiast' MFailComposeResult'. – newenglander

0

użycie tego dla dołączyć obraz w elektroniczną, testowane w iOS 4,5, 6

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