How do I attach a .txt data file saved to system.DocumentsDirectory to an email in Corona SDK

— Creating the text file —

local filePath_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
local file = filePath_Type, "r" )
if file then
  io.close( file )
  --Create an empty file--  
  local path_Type = system.pathForFile( "myTextFile.txt", system.DocumentsDirectory )
  local file = path_Type, "w+b" )
  file:write("My data inside file")
  io.close( file )

— Now, to email this file —

function showMailPicker()
  -- Create mail options --
  local options =
      to = { "",},
      subject = "Subject Text",
      body = "Email Body",
      attachment =
          { baseDir=system.DocumentsDirectory, filename="myTextFile.txt", type="text" },

   -- Send mail --
  native.showPopup("mail", options)

submitButton = display.newImageRect("myButton.png",100,40)
submitButton.x = 160
submitButton.y = 240

Sending mail in Landscape mode : cocos2d

I used several codes to fix this problem. Finally, this just fixed my problem.

in .h file :

#import <MessageUI/MFMailComposeViewController.h>

@interface Game : CCLayer <MFMailComposeViewControllerDelegate>

NSString *emailTitle;
NSString *emailBody;
UIImage *emailImage;
MFMailComposeViewController *picker;
-(id)initWithTitle:(NSString *)title body:(NSString *)body image:(UIImage *)image;

in .m file :

-(id) init
if( (self=[super init])) {

[self showMailPicker];

return self;

-(id)initWithTitle:(NSString *)title body:(NSString *)body image:(UIImage *)image
self = [super init];
if (self != nil) {
emailTitle = title;
emailBody = body;
emailImage = image;
[self showMailPicker];
return self;

picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
picker.modalPresentationStyle = UIModalPresentationFullScreen;
picker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[picker setSubject:emailTitle];
[picker setMessageBody:emailBody isHTML:YES];

[[CCDirector sharedDirector] pause];
UIViewController *rootViewController = (UIViewController *)[[[CCDirector sharedDirector] openGLView ] nextResponder];  // This will do it

[rootViewController presentModalViewController:picker animated:YES];
[picker release];

– (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
[[CCDirector sharedDirector] resume];
[controller dismissModalViewControllerAnimated: YES];


Validating Form Fields in Sencha Touch

Ext.regModel('exModel', {
	singleton: true,
	allowBlank: false,
    fields: [
        {name: 'f_name',  type: 'string'},
        {name: 'email',  type: 'string'},
        {name: 'num',type: 'int'},

    validations: [
        {type: 'presence',    field: 'f_name', error: 'must be present'},
        {type: 'format',      field: 'email',matcher: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/},
        {type: 'presence',    field: 'num',min:10}        

var data = Ext.create('exModel', {
			    email: '',
                            num: '12231'


var errors = data.validate();
alert('Form Validated');
alert('Form Not Validated');

Note: This will work on Sencha Touch V 1.1. Pls Check it on Sencha V 2.0.

Importance of product website in app marketing.

When you write your content for your website, your goal is to get visitors to learn about your app and want to click the “Buy Now” button that takes them over to the App Store and make them buy.  Your product website should be similar in look and feel to the app store product page. A carryover between the two sites will help build buyer confidence in your app and that you are serious about your business. All content on your website should express, convey, and highlight your unique message leaving no doubt in the minds of your customers as to the key values of your app.

These are important points to keep in mind, while making a website:-

  • Your content should quickly describe your app at the top of the page.
  • Your web content should be as entertaining as possible. Be sure to have a gallery of pictures showcasing your app.
  • The website should inform your visitor as to what your app can do.
  • You must educate your visitor with FAQ’s and videos. Always have a YouTube video / tutorial demonstrating your app.
  • Use highlighted keywords. (Hypertext links serve as one form of highlighting; typeface variations and color are others.)
  • Create meaningful subheadings (not “clever” ones).
  • Use bulleted lists just like on the App Store
  • Write short paragraphs. (Your readers will skip over any additional ideas if they are not caught by the first few words in the paragraph.)
  • Use the inverted pyramid style, starting with the conclusion first.
  • Descriptive words such as easy fun, fast and exciting are common terms used in searches. Include those in key words
  • Add a “Like it” or “Rate it” button and “tell a friend” button.
  • Send out an email or post an ad on your website that you are looking for early testers of your app.  You can offer them a free version of your app or some other small gifts
  • Keep your website updated frequently with the latest features, tips, and promotions.
  • Always have your “Buy Now” or “Download App Now” button prominently displayed on your home page,  paid version and Lite version  buttons should be there.
  • Create a structured survey form on your website through a service such as
  • Add a form to have email updates.
  • Page should target the correct audience. For eg;- if the app is for kids, page back ground etc should be for kids.
Mastering your web content will help you achieve greater sales of your app.