How to separate text on different lines in an email using ACTION_SEND?

Viewed 90

I was wondering, if anyone could help with this problem, I'm having trouble with ACTION_SEND. I have it setup that all the info is sent to the e-mail and to the address. My problem is I'm not sure if I can or if it possible to separate the information on different lines.

I would like to have my 1's item on one line and my 2's item on another line. I'm trying to get all my different number items to be put on different lines in the e-mail. Is that possible or do I need to redo the code to get that to happen?

Thank you in advance for your help and time!

Here's my code:

String message = pIN1 + " " + pD1 + " " + passM1 + " " + pU1 + " " + pIN2 + " " + pD2 + " " + passM2 + " " + pU2;

String[] to=new String[]{""};
String subject = ("Results");
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

if (passSN.equals("2")){
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");
    startActivity(Intent.createChooser(emailIntent, "Email"));
} else {
    Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
2 Answers

you can use the new line character \n to achieve what you want:

String message = pIN1 + "\n" + pD1 + "\n" + passM1;

Yes:

    String message = "";
    message += pIN1 + " " + pD1 + " " + passM1 + " " + pU1;
    message += "\n" + pIN2 + " " + pD2 + " " + passM2 + " " + pU2;

    String[] to = new String[]{""};
    String subject = ("Results");
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");

    startActivity(Intent.createChooser(emailIntent, "Send Email"));
Related