This is my solution for sending email:
public static void Send(Activity activity, String subject, String message, String to, String cc, String bcc, File attachedFile, String typeAttached) { Intent email = new Intent(Intent.ACTION_SEND); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[]{to}); email.putExtra(Intent.EXTRA_SUBJECT, subject); email.putExtra(Intent.EXTRA_TEXT, message); if(attachedFile!=null && attachedFile.exists() && !typeAttached.isEmpty()) { email.setType(typeAttached); email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachedFile)); } if(!cc.isEmpty()) email.putExtra(Intent.EXTRA_CC, new String[]{cc}); if(!bcc.isEmpty()) email.putExtra(Intent.EXTRA_BCC, new String[]{bcc}); try { activity.startActivity(Intent.createChooser(email, "Please select your mail client:")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(activity, "There is no email client installed", Toast.LENGTH_SHORT).show(); } }
And here is an example post:
String message = "Hello,<br/><br/>this is a test message!";
I hope I helped you!
source share