title: Will anyone give example for sending mail with attachment in android
body: <p>I need to develop a small Email Application which i have to generate CSV and mail that CSV document using android. I have to send this attachment without saving into storage. I found difficult in attaching the CSV file using file writer and my code as follows :</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      buttonSend = (Button) findViewById(R.id.buttonSend);
  
      textTo = (EditText) findViewById(R.id.editTextTo);
      textSubject = (EditText) findViewById(R.id.editTextSubject);
      textMessage = (EditText) findViewById(R.id.editTextMessage);
  
      buttonSend.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
            String to = textTo.getText().toString();
            String subject = textSubject.getText().toString();
            String message = textMessage.getText().toString();
  
            Intent email = new Intent(Intent.ACTION_SEND);
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
            //email.putExtra(Intent.EXTRA_CC, new String[]{ to});
            //email.putExtra(Intent.EXTRA_BCC, new String[]{to});
            email.setType("text/csv");
            email.putExtra(Intent.EXTRA_SUBJECT, subject);
            email.putExtra(Intent.EXTRA_TEXT, message);
          email.putExtra(Intent.EXTRA_STREAM,generateCsvFile("testdata.csv"));
  
            //need this to prompts email client only
  
            startActivity(Intent.createChooser(email, "Choose an Email client :"));
  
          }
      });
  }
  public static FileWriter generateCsvFile(String sFileName) throws IOException
     {
         FileWriter writer;
         writer = new FileWriter(sFileName);
         writer.append("DisplayName");
         writer.append(',');
         writer.append("Age");
         writer.append('\n');
  
         writer.append("RajeshV");
         writer.append(',');
         writer.append("26");
         writer.append('\n');
  
         writer.append("Mrithula");
         writer.append(',');
         writer.append("29");
         writer.append('\n');
  
        return writer;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I got problem in this line :</p>
  
  <pre><code>email.putExtra(Intent.EXTRA_STREAM,generateCsvFile("testdata.csv"));
  </code></pre>