Quantcast
Viewing all articles
Browse latest Browse all 8068

Can't create an mail attachment out of mapview.toImage()-Blobfile

I wrote a simple script that is supposed to make a screenshot of a mapview. I want to send that pic via mail to an email-adress as an attachment. However the attachment is always empty when I try to append the file. (see code below) :-(

I played around a little bit, and the only time I get an attachment is, when use createTempFile, instead of getFile. However since googleMail only accepts real filetypes like jpg. etc. It doesnt work because the Tempfile has a cryptic name without filetype-ending. So the googleMailer refused to send the mail with the "illegal file".

Any idea what i do wrong or how to perform this?

var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    userLocation:true
});
 
var theMap = mapview.toImage();
 
file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'map.jpg');
file.write(theMap);
 
var emailDialog = Ti.UI.createEmailDialog()
emailDialog.subject = "Hello from Titanium";
emailDialog.toRecipients = ['my@email.com'];
emailDialog.messageBody = '<b>Maptest</b>';
emailDialog.addAttachment(file);
emailDialog.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>