i've used the code below it was the accepted answer that was given at http://developer.appcelerator.com/question/135462/save-screenshot-temporarily-then-retrieve-when-ready
But when the email dialog box opens it shows a attached file which was screenshot but after sending email there is no attachment in received email.it means screenshot is not sending.
can anyone tell what's wrong in this code???
var win = Ti.UI.createWindow({
// backgroundColor : '#666666'
backgroundColor : 'red',
// backgroundImage : 'img/1.jpg'
});
var btn = Ti.UI.createButton({
width : 100,
height : 30,
title : 'Test'
});
btn.addEventListener('click', function(e) {
Titanium.Media.takeScreenshot(function(e) {
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'test.png');
f.write(e.media);
var emailDialog = Titanium.UI.createEmailDialog();
emailDialog.setToRecipients(['test@gmail.com']);
emailDialog.setSubject('test');
emailDialog.setMessageBody('testing......');
emailDialog.setHtml(true);
emailDialog.setBarColor('black');
emailDialog.addAttachment(f.read());
emailDialog.addEventListener('complete', function(e) {
if(e.result == emailDialog.SENT) {
alert("message was sent");
}
});
emailDialog.open();
});
});
win.add(btn);
win.open();
The addAttachment
function can take a blob, you don't have to save it to disk. Also, this may not be working because you may not have write access to the applicationDataDirectory
.
Instead just pass the supplied blob from e.media
like this:
Titanium.Media.takeScreenshot(function(e) {
var emailDialog = Titanium.UI.createEmailDialog();
// Get the supplied blob and attach
emailDialog.addAttachment(e.media);
// ...... add other email things here
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.