我想在不显示 MFMailComposeViewController 的情况下发送电子邮件。我只想将电子邮件发送到一些电子邮件序列(因此用户应该只看到我的微调器,而不是带有发送按钮的 MFMailComposeViewController)。
我知道发送电子邮件的唯一方法是:(但这不是我想要的)
-(void)showMessageController:(id)sender
{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail])
{
[self displayComposerSheet];
}
else
{
[self launchMailAppOnDevice];
}
}
else
{
[self launchMailAppOnDevice];
}
}
// Displays an email composition interface inside the application. Populates all the Mail fields.
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
[appDelegate setNavigationBarTextured:YES navigationBar:picker.navigationBar];
picker.mailComposeDelegate = self;
[picker setSubject:@"Please, look at my photo!"];
// Attach an image to the email (mydata - data of the image)
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"photo"];
// Fill out the email body text
NSString *emailBody = @"Hello!\nPlease, have a look at my photo!";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
// NSString *recipients = @"mailto:first@example.com?cc=second@example.com,third@example.com&subject=Hello from California!";
NSString *recipients = @"mailto:subject=Please, look at my photo!";
NSString *body = @"&body=Hello!\nPlease, have a look at my photo!";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
如何在没有 MFMailComposeViewController 的附加屏幕的情况下发送电子邮件?
先感谢您!