SHARE
TWEET

Untitled

a guest Oct 4th, 2017 398 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.leo.enviar;
  2.  
  3. import android.content.Intent;
  4. import android.net.Uri;
  5. import android.os.Environment;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.os.Bundle;
  8. import java.io.File;
  9.  
  10. import java.io.File;
  11.  
  12. public class Main6Activity extends AppCompatActivity {
  13.     String xlsname="archivo32.xls";
  14.  
  15.     @Override
  16.     protected void onCreate(Bundle savedInstanceState) {
  17.         super.onCreate(savedInstanceState);
  18.         setContentView(R.layout.activity_main6);
  19.  
  20.  
  21.         String[] mailto = {"ing.eo@hotmail.com"};
  22.         Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath(),xlsname ));
  23.         Intent emailIntent = new Intent(Intent.ACTION_SEND);
  24.  
  25.         emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
  26.         emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Calc PDF Report");
  27.         emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Hi PDF is attached in this mail. ");
  28.         emailIntent.setType("application/excel");
  29.         emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
  30.         startActivity(Intent.createChooser(emailIntent, "Send email using:"));
  31.     }
  32.    
  33. @Override
  34. protected void onCreate(Bundle savedInstanceState) {
  35.     super.onCreate(savedInstanceState);
  36.     setContentView(R.layout.activity_main9);
  37.  
  38.     String[] mailto = {"elgermanolargo@gmail.com"};
  39.     //----------------------
  40.    // Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath(),xlsname ));
  41.     Uri uri = Uri.fromFile(new File( getFilesDir().toString()+"/"+"miCarpeta/",xlsname ));
  42.    
  43. emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
  44.     emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Calc PDF Report");
  45.     emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Hi PDF is attached in this mail. ");
  46.     emailIntent.setType("application/excel");
  47.     emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
  48.     startActivity(Intent.createChooser(emailIntent, "Send email using:"));
  49. }
  50.    
  51. String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString();
  52. new File(SD_CARD_PATH + "/" + xlsname);
  53.    
  54. Log.i(TAG, "PATH: " + Environment.getExternalStorageDirectory().getAbsolutePath());
  55.    
  56. /storage/emulated/0/archivo32.xls
  57.    
  58. String fileName ="tests-example.xls";
  59. String MIME_TYPE = "application/excel";
  60.  
  61.         Log.i(TAG, "PATH: " + Environment.getExternalStorageDirectory().getAbsolutePath() +"/Android/data/");
  62.  
  63.         String[] mailto = {"correo@gmail.com"};
  64.  
  65.         Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/Android/data/", fileName ));
  66.         Intent emailIntent = new Intent(Intent.ACTION_SEND);
  67.  
  68.         emailIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
  69.         emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Mi reporte");
  70.         emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Envio mi archivo excel. ");
  71.         emailIntent.setType(MIME_TYPE);
  72.         emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
  73.         startActivity(Intent.createChooser(emailIntent, "Selecciona como deseas enviar el archivo:"));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top