Enviar Anexo

  • Respostas:0
Darlan Rojas
  • Posts no fórum: 1

26/12/2017, 20:16:37 via Web

Olá sou novo aqui...
Bom vou direto no assunto, não estou conseguindo enviar o anexo do app, segue abaixo a logica:

private void enviar(String[] to, String[] cc,
String asunto, String mensaje) {
String pathname= Environment.getExternalStorageDirectory().getAbsolutePath();
String filename="src/main/assets/curso.pdf";
File file=new File(pathname, filename);
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
//String[] to = direccionesEmail;
//String[] cc = copias;
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
emailIntent.putExtra(Intent.EXTRA_CC, cc);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, asunto);
emailIntent.putExtra(Intent.EXTRA_TEXT, mensaje);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
emailIntent.setType("text/pdf");
startActivity(Intent.createChooser(emailIntent, "Email "));
}
}

OBS: quando mudo o endereço tipo:String filename="Download/curso.pdf"; o anexo vai para o e-mail. alguém pode ajudar ai.
Obrigado

Responder