我已使用MFMailComposeViewController
在我的代码中发送电子邮件。我也使用可达性代码来检查互联网连接。互联网连接工作正常。每当我用我的代码发送邮件时,我都会收到邮件已发送的消息。但我没有收到任何邮件。没有从应用发送的电子邮件。我不知道这背后的原因。如果有人知道如何摆脱这个问题,请为我提供一些解决方案。电子邮件功能无法正常工作
-(void)sendemail
{
emailBody = @"";
mail = [[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Report"];
NSURL *url = [NSURL URLWithString:imagePath];
NSData *data = [NSData dataWithContentsOfURL:url];
[mail addAttachmentData:data mimeType:@"image/jpg" fileName:@"licence.png"];
NSMutableString *breakline = [[NSMutableString alloc]init];
[breakline appendString:[NSString stringWithFormat:@"<br>"]];
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[mail setToRecipients:toRecipients];
emailBody = [emailBody stringByAppendingFormat:@"%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@",@"Name: ",namestr,breakline,@"Address: ", addresstr,breakline,@"Landmark: ",landmarkstr,breakline,@"City: ", citystr,breakline,@"State: ", statestr,breakline,@"PIN: ", pinstr,breakline,@"Contact No: ",phonestr,breakline,@"Licence:",licencestr,breakline,@"Email Id", emailstr];
[mail setMessageBody:emailBody isHTML:YES];
if (mail != nil) {
[self presentModalViewController: mail animated: YES];
[mail release];
}
}
谢谢大家。
请检查是否data''有有效数据。 – Ilanchezhian 2012-01-05 06:45:07
也检查我们是否可以使用'if([MFMailComposeViewController canSendMail])发送邮件' – Ilanchezhian 2012-01-05 06:47:02