I just want to send an email with a file attachment. But i m getting an error as cannot set property "subject" of null to " Hello from Titanium".
code is : var emailDialog = Titanium.UI.createEmailDialog() emailDialog.subject = "Hello from manu"; emailDialog.toRecipients = ['ranjanmanu@yahoo.com']; emailDialog.messageBody = '<b>U Rock!</b>'; var f = Ti.Filesystem.getFile('cricket.wav'); emailDialog.addAttachment(f); emailDialog.open();
Cant recognise whats the error ...please help me.
thanks
4 Answers
emailDialog.setSubject('Hello from manu'); emailDialog.setMessageBody('U ROCK!');they have methods to set those, properties aint working.
o.O , something is wrong...
can you try this code?
var emailDialog = Ti.UI.createEmailDialog(); emailDialog.toRecipients = ['testmail@text.com']; emailDialog.open();does this work? if not then something is wrong with your SDK
Manu,
It looks like maybe you are having an issue with another part of your code, or your build is messed up. Try clearing out your <project directory>/build/android directory (or if your using titanium studio, click project menu, then clean) If that does not work we might need to see some more of your surrounding code to see what the issue might be.
Mark i did clear the directory....so my complete code is this,....please have a look thanks...
var win = Titanium.UI.currentWindow; win.add(Titanium.UI.createLabel({ text: "", color:'red', font:{fontSize:20,fontFamily:'Helvetica Neue'}, }));
var alert = Titanium.UI.createAlertDialog({ title: 'Virus Found', message: 'Do you want to delete the Virus', buttonNames: ['Yes', 'No'], cancel: 1 }); alert.addEventListener('click', function(e) { Titanium.API.info('e = ' + JSON.stringify(e)); switch (e.index) { case 0: Titanium.API.info('Clicked button 0 (YES)'); win.add(Titanium.UI.createLabel({ text: "Three Trojan horses deleted", color:'red', font:{fontSize:20,fontFamily:'Helvetica Neue'}, })); break;
//This will never be reached, if you specified cancel for index 1
case 1: Titanium.API.info('Clicked button 1 (NO)');
win.add(Titanium.UI.createLabel({
text: "As you wish )",
color:'red',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
}));
default:
break;
} });
alert.show();
var input_2 = Titanium.UI.createTextField({ top: 20, left: 10, width: 200, height: 44 }); win.add(input_2); var button2 = Titanium.UI.createButton( { title : "Alert box", top: 70, left: 10, width: 200, height: 44 } ); win.add(button2); button2.addEventListener( "click", function messageCallback(e){ var alertDialog = Titanium.UI.createAlertDialog({ title: 'Hello', message: 'You got mail' + " " + input_2.value + '.', buttonNames: ['OK','Doh!'] }); alertDialog.show();
}); var button3 = Titanium.UI.createButton( { title : "To show activity indicator", top: 130, left: 10, width: 200, height: 44 } ); win.add(button3); button3.addEventListener( "click", function messageCallback(e){ var actInd = Titanium.UI.createActivityIndicator({ height:50, width:10 }); actInd.show();
}); var emailDialog = Titanium.UI.createEmailDialog() ; emailDialog.setSubject('Hello from manu'); emailDialog.toRecipients = ['ranjanmanu@yahoo.com']; emailDialog.setMessageBody('U ROCK!'); var f = Ti.Filesystem.getFile('cricket.wav'); emailDialog.addAttachment(f); emailDialog.open();
Your Answer
Think you can help? Login to answer this question!