电子邮件问题:想发送电子邮件,无需额外的窗口 [英] Email issue: want to send email without additional window
问题描述
我想发送电子邮件,而不显示MFMailComposeViewController。我只想发送电子邮件到一些电子邮件序列(所以用户应该只看到我的微调器,而不是MFMailComposeViewController与发送按钮)。
I want to send email without showing MFMailComposeViewController. I just want to send email to some sequence of emails (so user should see only my spinner, not MFMailComposeViewController with send button).
发送电子邮件的唯一方法我知道是(但不是我想要的)
The only way to send emails I know is: (but it's not I want)
-(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的附加屏幕,我如何发送电子邮件?
How can I send email without additional screen of MFMailComposeViewController?
提前谢谢!
推荐答案
网页服务。编写一个Web服务,将邮件正文和收件人的电子邮件地址,主题等作为参数,并从后端发送邮件。
You can do it by Web services. Write a web service that takes message for Email body and receiver's email address, subject etc as parameters and sends mail from backend.
这篇关于电子邮件问题:想发送电子邮件,无需额外的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!