3

I'm trying to use this solution but Eclipse still cant resolve "Attachment" and "DataService".

I've imported mail.jar and activation.jar, what could I be doing wrong? I've tried countless other sending email solutions on SO/Google but I couldn't get any of them to work with my attachment and send HTML emails.

Any help would be appreciated.

Community
  • 1
  • 1
MrEngineer13
  • 38,642
  • 13
  • 74
  • 93

2 Answers2

2

If you need to construct email to be sent by user manually (open his mail program with new email and attachment) you can use this code:

Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:" ));
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MESSAGE");
File toAttach = new File("/path/to/your/file");
Uri uri = Uri.fromFile(toAttach);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(emailIntent);
OleGG
  • 8,589
  • 1
  • 28
  • 34
0

I used this tutorial and changed

    messageBodyPart.setText(_body); 

to

    messageBodyPart.setContent(_body, "text/html");
MrEngineer13
  • 38,642
  • 13
  • 74
  • 93