Ted pottel
Ted pottel

Reputation: 6983

My attachment is not getting sent when I try to send out a attchment

I have a file called card1.jpg stored in the assets folder. When my program runs, it shows a paaper clip in the email and it seems like everything works when I press send. But.... no attachment ever gets sent.

code: case R.id.butEmail: Intent msg = new Intent(Intent.ACTION_SEND); msg.setType("text/plain"); msg.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"}); msg.putExtra(Intent.EXTRA_TEXT, "attach image"); msg.putExtra(Intent.EXTRA_SUBJECT, "Just Feet");

            String rawFolderPath = "file://android_assets//card1.jpg";

            Uri emailUri = Uri.parse(rawFolderPath );
            msg.putExtra(Intent.EXTRA_STREAM, emailUri);
            msg.setType("application/jpg");
            startActivity(Intent.createChooser(msg, "Emailinng..."));

            break;

Upvotes: 0

Views: 110

Answers (1)

karn
karn

Reputation: 6033

Two points:

  • You are using wrong path to the asset folder. There should be three slashes. And you need not to use double slashes for the folder hierarchy. The correct path to the asset folder is:

    file:///android_assets/folder1/folder2/image.png"

  • Your asset folder is local to your application(your process) so, applications outside your process(application) cannot access your asset folder.

Upvotes: 0

Related Questions