1

What is the type i can use for intent for sending an email with an html page attachment? Whatever type i use, the sent mail contains an empty page as an attachment

Here's some code

String root = "/data/data/com.email/files/";
                String fileName = "Payslip.html";
                if (true) {
                    attachment = new File(root, fileName);
                }

                final Intent emailIntent = new Intent(

                android.content.Intent.ACTION_SEND);

                emailIntent.setType("application/octet-stream");

                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,

                new String[] { address.getText().toString() });

                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,

                subject.getText());

                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,

                emailtext.getText());

                emailIntent.putExtra(Intent.EXTRA_STREAM,
                        Uri.fromFile(attachment));

                EmailActivity.this.startActivity(Intent.createChooser(
                        emailIntent,

                        "Send mail..."));
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
Manoj Kumar
  • 1,510
  • 3
  • 20
  • 40

1 Answers1

0

As for now, we can use context.getFilesDir() to retrieve a File object to the "files" directory. With that you can also get another File object to your stored HTML page. You can also use the File.exists() and File.isFile() method for checking. Thanks for Christian Lisching

Community
  • 1
  • 1
Manoj Kumar
  • 1,510
  • 3
  • 20
  • 40