メールプログラムに問題なくアクセスでき、「送信」を押すとシューという音が聞こえ、メールが閉じてアプリに戻りますが、実際のメールは送信されません。
これが私がメールに使用しているコードです。私が間違っていることについてのアイデアはありますか?
(シミュレーターではなく、実際のデバイスで iOS6 を使用しています。)
-(void)openMail {
//Open Mail program and create email with haiku attached as image.
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:[NSString stringWithFormat:@"subject"]];
UIImage *myImage = [self createImage];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"xxxxx"];
NSString *emailBody = @"I thought you might like this haiku from the xxxxx iPhone app.";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentViewController:mailer animated:YES completion:NULL];
}
//Unless it's not possible to do so, in which case show an alert message.
else
{
self.alert = [[UIAlertView alloc] initWithTitle:@"I'm sorry." message:@"Your device doesn't seem to be able to email this haiku. Perhaps you'd like to tweet it or post it on Facebook instead?" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[self.alert show];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self dismissViewControllerAnimated:YES completion:Nil];
}