Sending an email with attachments programmatically on Android

前端 未结 3 1747
遇见更好的自我
遇见更好的自我 2020-12-09 10:17

I wish to implement a button that upon pressing it will open the default email client with an attachment file.

I am following this, but am getting an error message o

3条回答
  •  我在风中等你
    2020-12-09 10:29

    Try to use this.It is working...

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
                        emailIntent.setType("*/*");
    
                        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(listVideos.get(position).getVideoPath())));//path of video 
                        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    

    Thanks

提交回复
热议问题