I´m trying to email an image using javamail. But I get a FileNotFoundException:
05-22 15:05:29.300: W/System.err(29154): javax.mail.MessagingException: IOException while sending message;
05-22 15:05:29.300: W/System.err(29154): nested exception is:
05-22 15:05:29.300: W/System.err(29154): java.io.FileNotFoundException: /content:/media/external/images/media/35367: open failed: ENOENT (No such file or directory)
I think this is the part of the method which causes the exception:
System.out.println(params[1]);
File filename=new File(params[1]); // params[1]=content://media/external/images/media/35367
DataSource source = new FileDataSource(filename);//uses aditional
messageBodyPart.setDataHandler(new DataHandler(source));
But if I understood the API right an absolute uri isn´t a problem for a File-object. And I think it isn´t possible that the file doesn´t exist, because right before this method I´m setting an ImageView by this uri. Could this be the problem? Something like that android automatically locks this file?
I also set Read and Write rights at the AndroidManifest:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Just comment if you need further information.
EDIT: I looked up the path to the image I´m trying to send and it differs completely from the path where it is saved...