I'm writing an app which will be in a kind of kiosk. Many people will use it. I need to send emails from it but without the users having to log in to 开发者_高级运维their own accounts, so basically it will take their personal email address and then email them using the default email address already setup on the iPad / iPhone.
However, I don't want any of the emails to send straight away - I need them cached, and then later - when an Admin says so, it should send them then - the reason is that whilst the app may be on a device that has Internet access it may be 3G... or no access at all - but I need it to wait until it's out of the kiosk and back somewhere where they can send all the emails.
Is this possible with the standard built in email functionality?
Or is this the sort of thing that an external mail server should be used for? If so, does anyone know of a good tutorial on having an 'in-app' email UIView then sends the emails and any attachments off to an external server for sending later?
Thanks so much
I am not quite sure if I get your point. You only want to send an email when you can be sure to have the correct internet connection ?
By using the standard Mail Composer the created email will be passed to the mail app and be placed in the Apps Outbox until an internet connection is available to send the mail. You also could check before presenting the mail composer to have a specific connection (e.G. WLAN ). The thing is, the user has to press the send button to pass the mail into the mail apps outbox.
You could compose a mail with an attachment like that (in your .m file):
-(void)displayComposerSheet
{
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setSubject:@"This is the subject of my mail"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"user@host.com"];
[mailComposer setToRecipients:toRecipients];
// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"ImageName" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailComposer addAttachmentData:myData mimeType:@"image/png" fileName:@"ImageName"];
//present the composer
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
}
Keep in mind to include into the .h file of your ViewController:
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
Also make the Class respond to the MFMailComposeViewControllerDelegate
protocol.
精彩评论