0

I want my mobile app to send an email to the user who is logged in the app with some additional info about his health. I have searched, but only found how to compose an email and send it to someone, I didn't find some tutorials that show how you can make your app to send an email to the user. Do you know if this is possible to implement? If you have any tips, or you know some good tutorials, please share with me the info.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Im pretty much sure you need some backend for it. Maybe firebase has sending emails? – Gralls Jun 17 '20 at 20:19
  • Firebase has some methods that sends email with some link in order to change account password. But I don't know if I can use it to achieve want I want. I didn't think at this way – Denisa Mărginean Jun 17 '20 at 20:29

1 Answers1

0

Not so sure if its possible, sorry. However you can compose a mail, and add data to it programmatically in order to read it all before pressing 'SEND' by yourself

ASSUMING:

  1. You have the user' mail who is logged STORED in a variable such a String.
  2. We add data and compose a MAIL so device must have at least one mail app. I've tested this with GMAIL app.

Code:

//Define your mail:
String USERmail = "user@home.com";
String HealthData = "70kg";
String file1 = "/Dir1/Xray.jpg"     //Data you might need to attach to mail
String file2 = "/Dir1/Fat.jpg"      //Data you might need to attach to mail

//=======================Add files to variable - bucle might be needed==========
String[] attached = new String[2];     // 2 number of files
attached[0] = file1;
attached[1] = file1;

//=========================Compose Mail========================================
Intent sendintent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendintent.putExtra(Intent.EXTRA_EMAIL, new String[]{USERmail});
sendintent.putExtra(Intent.EXTRA_SUBJECT, "String cointaining subject");
sendintent.putExtra(Intent.EXTRA_TEXT, "Greetings Text" +yourdata);  //Add your health data

//==============Attach Method in case any data needed to be sent==============
ArrayList<Uri> uris = new ArrayList<Uri>();
for(String filepath : attached)
   {File fileATCH = new File(filepath);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
   }
sendintent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
sendintent.setType("text/plain");

//=============================================================================== startActivity(Intent.createChooser(sendintent, "Send health mail...")); //Choose GMAIL or any other mail app you might have. I've only tested it with GMAIL.

I hope this helps!

WIzardJD
  • 1
  • 3