Many apps uses a "Challenge" button..when pressed..they compose a e-mail with images
i.e Doodle Jump does this
A nice way to promote the app.
Anyone have an idea how to send a e-mail with images in the body of the mail?
A fast, easy to use, free, and community supported 2D game engine
Many apps uses a "Challenge" button..when pressed..they compose a e-mail with images
i.e Doodle Jump does this
A nice way to promote the app.
Anyone have an idea how to send a e-mail with images in the body of the mail?
Just looked thru a Challenge e-mail...they just included the images via links to external url's
where the images are located
so now I need to know who to compose that e-mail..anyone already did this?
Take a look at MFMailComposeViewController.
Example:
MFMailComposeViewController *mailController = [[[MFMailComposeViewController alloc] init] autorelease];
[mailController setMessageBody:@"Your e-mail contents" isHTML:no]; // HTML is also possible
mailController.mailComposeDelegate = self;
[self presentModalViewController:mailController animated:yes];I took a different approach to my (non-cocos2d) game. I have several in-app email options, I'll post the code but basically what I did was to add a folder with the items (images, pdf's, etc) that I wanted to email (named HTML). This way if the user pulls up the email, even in airplane mode (yeah I know, but hey users are stupid... ;-]). So it all boils down to using the right mime type for your attachment. Anyhow... here's some code which is by no means complete - just give you an idea:
#pragma mark -
#pragma mark Compose Mail
// Displays an email composition interface inside the application. Populates all the Mail fields.
-(void)displayComposerSheet {
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
switch (emailType) {
case 0: {
[picker setSubject:[NSString stringWithFormat:@"Game Support"]];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"email@gmail.com"];
[picker setToRecipients:toRecipients];
NSString *emailBody = @"> Please provide as much detail as you can < \n\n\n\n";
[picker setMessageBody:emailBody isHTML:NO];
}
break;
case 1: {
[picker setSubject:[NSString stringWithFormat:@"... is a great game!"]];
NSString *emailBody = @"Check out this awesome iPhone game, it's called ....\n\nhttp://website.com/link.html";
[picker setMessageBody:emailBody isHTML:NO];
}
break;
case 2: { //quickstart
[picker setSubject:[NSString stringWithFormat:@"Quick Start"]];
NSString *emailBody = @"Attached is the Quick Start PDF.\n\nhttp://website.com";
[picker setMessageBody:emailBody isHTML:NO];
// Attach a text to the email
NSString *pdfFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"HTML/QuickStart.pdf"];
NSData *myTXT = [NSData dataWithContentsOfFile:pdfFilePath];
[picker addAttachmentData:myTXT mimeType:@"text/plain" fileName:@"QuickStart.pdf"];
}
break;
case 3: { //usersguide
[picker setSubject:[NSString stringWithFormat:@"Users Guide"]];
NSString *emailBody = @"Attached is the Users Guide PDF.\n\nhttp://website.com";
[picker setMessageBody:emailBody isHTML:NO];
// Attach a text to the email
NSString *pdfFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"HTML/UsersGuide.pdf"];
NSData *myTXT = [NSData dataWithContentsOfFile:pdfFilePath];
[picker addAttachmentData:myTXT mimeType:@"text/plain" fileName:@"UsersGuide.pdf"];
}
break;
case 4: { //iBook
[picker setSubject:[NSString stringWithFormat:@"iBook: Users Guide"]];
NSString *emailBody = @"Attached is the Users Guide iBook. Save the attachment, then unzip the file and finally drag the \"Users Guide v2.0 - MeachWare.epub\" file into iTunes and sync your iPad.\n\nhttp://website.com";
[picker setMessageBody:emailBody isHTML:NO];
// Attach a text to the email
NSString *pdfFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"HTML/Guide.epub.zip"];
NSData *myTXT = [NSData dataWithContentsOfFile:pdfFilePath];
[picker addAttachmentData:myTXT mimeType:@"application/zip" fileName:@"Guide.epub.zip"];
}
break;
default:
break;
}
#ifdef LITE_VERSION
// Attach an image to the email
NSString *iconpath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"HTML/EmailIconLite.png"];
NSData *icondata = [NSData dataWithContentsOfFile:iconpath];
[picker addAttachmentData:icondata mimeType:@"image/png" fileName:@"AppIcon"];
#else
// Attach an image to the email
NSString *iconpath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"HTML/EmailIconFull.png"];
NSData *icondata = [NSData dataWithContentsOfFile:iconpath];
[picker addAttachmentData:icondata mimeType:@"image/png" fileName:@"AppIcon"];
#endif
[self presentModalViewController:picker animated:YES];
[picker release];
}
Edit: Oh and I found you need to use a folder so that your .png files don't get compressed, otherwise when you email to a non-iDevice they won't display.
Ha! I have found what I have looking for.
It's in the MailComposer sample project from Apple
You must log in to post.