Thursday, April 11, 2013

[android help] How to Attach files with sending mail in android application?

email - How to Attach files with sending mail in android application? - Stack Overflow



















I am sending mail through my application. For that I am using following code.



Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}


It just work fine but i want to attach an xml file with it. Is it possible? How?


























There are lots of similar questions asked with perfect solution in Stack Overflow already.


You can have look to few : here and here and here


Solution is to use with email intent : one more putExtra with Key-Extra_Stream and Value-uri to file.


And please go through the FAQ to undersatand How to better benifit from the site.


























default






.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...