Via : OpenAndroid.in
Tags : #Source_Code, #Tutorial
Orginal Post: How to Send Email in Android Programming

android_mobile_email_compose


Sending Email In Android Programming



In Android we can send Email  using following Code
[sourcecode lang="java"]</pre>
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]"recieveremail@gmail.com");
i.putExtra(Intent.EXTRA_SUBJECT, "Subject of Mail");
i.putExtra(Intent.EXTRA_TEXT , "The Message Body");
try
startActivity(Intent.createChooser(i, "Sending mail..."));


finally

// Code to execute when unable to send Email

<pre>
[/sourcecode]





To attache files in Email you need to use Intent.EXTRA_STREAM

For Ex:

[esll id="59445744" description=""]

[sourcecode]</span>

ArrayList uris = new ArrayList();

i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivityForResult(Intent.createChooser(i, "Sending multiple attachment"), 12345);

[/sourcecode]

[/esll]




Via : OpenAndroid.in
Tags : #Source_Code, #Tutorial
Orginal Post: How to Send Email in Android Programming

0 comments:

Post a Comment

 
Top