Re: [android-developers] email pdf attachment 0kb !
Dear Jag,
I have the same problem when send an attachment to the email. I solved this by saving the pdf file in the sd card.
Regards
Deepesh
On Thu, May 31, 2012 at 1:15 AM, Jags <jagatm@gmail.com> wrote:
i have a pdf file in /data/data/mypkg/pdfs/myfile.pdf
i am using this url debugged and saw it.
it is world_readable
(how to verify in adb shell, BTW)
i use following code to send attachment
but mail reaches with a pdf file attached with 0kb size
what could be the issue ? i can adb pull and see it in my pc though
private void emailPDF(String fullpath) {
File pdfFile = new File(fullpath);
if (pdfFile.exists()) {
try {
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
//
String address = "";
String subject = "Please find attached the docs";
String emailtext = "Please find attached the docs";
//
emailIntent.setType("application/pdf");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { address });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
subject);
// emailIntent.putExtra(Intent.EXTRA_STREAM,
// Uri.parse("file://" + fullpath));
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(pdfFile));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
emailtext);
this.startActivity(Intent.createChooser(emailIntent,
"Send mail..."));
} catch (Throwable t) {
Toast.makeText(this, "Request failed: " + t.toString(),
Toast.LENGTH_LONG).show();
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home