Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5443] iOS: EmailDialog not sending attachments

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2011-10-14T14:50:30.000+0000
Affected Version/sn/a
Fix Version/sSprint 2011-41
ComponentsiOS
Labelsattachment, bug, email, emaildialog, image, ios
ReporterKarol Pomaski
AssigneeSabil Rahim
Created2011-10-05T12:08:04.000+0000
Updated2017-03-02T22:20:46.000+0000

Description

Problem

While sending the image files as a attachment using EmailDialog the receive image is empty.

Reproducible Steps

1. Execute the project that was attached 2. Install the application to some iOS device 3. Send an email to you 4. Check your inbox - the image received is empty

Sample Code

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});

win1.open();
var emailDialog = Titanium.UI.createEmailDialog();

emailDialog.subject = 'Take a look at this great app I found!';

emailDialog.toRecipients = [];

emailDialog.messageBody = "u";

var f = Ti.Filesystem.getFile('off.png');


if(f.exists())

{

emailDialog.addAttachment(f);

}

else

{

emailDialog.messageBody = "test";

}

emailDialog.open();

Associated HelpDesk Ticket

http://appc.me/c/APP-353882

Attachments

FileDateSize
emaildialog.zip2011-10-05T12:08:04.000+00002877242

Comments

  1. Sabil Rahim 2011-10-13

    This is not a problem on our SDK, This happens as the PNG files in the resources folder are being transfered to iOS device ,the build process compresses the file for optimization and as a result of which any PNG file in the app's resources folder that you may send as a email attachment won't show up on a computer , but can be seen through any iOS device. NOTE : THIS ONLY HAPPENS FOR PNG FILES AND NO OTHER TYPES OF FILE HAVE ANY PROBLEM ... AND HAPPENS FOR PNG FILES SHIPPED ALONG WITH THE APP, IT SHOULDN'T CREATE A PROBLEM IF YOU ARE TYRING TO SEND A PNG FILE FROM THE PHOTO LIBRARY INSIDE THE PHONE.
  2. Sabil Rahim 2011-10-14

    blog post that explains the whole process . http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html
  3. Blain Hamon 2011-10-14

    Further commentary: To turn off the png compression would be a speed hit to the app in general, possibly to file size as well, and is generally frowned upon. Emailing resources that were compiled into the app is the exception, not the norm. Solutions: 1) Save the png under a different extension so it doesn't get compressed at build time 2) Use a different file type 3) Open the png, resize it to itself, and save the new, uncompressed image and send that. All of these solutions to this odd edge case can be done completely in javascript.
  4. Sabil Rahim 2011-10-14

    //workaround code : Titanium.UI.setBackgroundColor('#000'); var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); win1.open(); var emailDialog = Titanium.UI.createEmailDialog(); emailDialog.subject = 'Take a look at this great app I found!'; emailDialog.toRecipients = []; emailDialog.messageBody = "u"; //var f = Ti.Filesystem.getFile('off.png'); <- Remove this line var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'convert.PNG'); //<-- insert file.write(Ti.UI.createImageView({image:'off.PNG',}).toImage()); //<-- insert if(f.exists()) { emailDialog.addAttachment(f); } else { emailDialog.messageBody = "test"; } emailDialog.open();
  5. Reggie Seagraves 2011-10-14

    This is a known issue with the way Apple preprocesses PNG files for inclusion into an app. Use the workaround in the ticket for png files from the Resources directory.
  6. Lee Morris 2017-03-02

    Closing ticket as invalid.

JSON Source