Can any body share any code snippet in order to send an attachment with an email using android
native client.
Thanks & Regards,
This is what I found,
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
i.setType("audio/amr");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + attachmentFilePath));
startActivity(i);
Related
As we use "content://sms/inbox" for sms inbox, do we have anything like this for email.I want to read email from after selecting email client.I tried the following the code
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setType("message/rfc822");
Uri data = Uri.parse("content://mail/inbox");
intent.setData(data);
startactivity(intent);
I dont want to send mail,just to read the mail,So i cant use mailto:
You should use this :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);
How to send mail through only email clients from my android application.
I am using the below code in my application but its opeing messeges and bluetooth also. I need only Email clients like Gmail or yahoo.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "mailto#gmail.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
startActivity(Intent.createChooser(emailIntent, "Email:"))
Just Go on to Use this Code...It will always invoke your default Email Client.
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + subject + "&body=" + body);
intent.setData(data);
startActivity(intent);
Is this of any help? This one is using the gmail client it seems.
Intent URI to launch Gmail App
I use this way to avoid choosing other app but default email client.
Intent it = new Intent(Intent.ACTION_SEND);
it.setType("text/plain");
it.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddr});
it.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
it.putExtra(Intent.EXTRA_TEXT, emailContent);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + emailAddr));
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = emailIntent.resolveActivityInfo(mContext.getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
it.setPackage(info.packageName);
}
mContext.startActivity(it);
I hope it can help you ~
I made it work using this:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("mp3/3gp");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "recording voice");
Uri eri=Uri.parse(rlm.getPlayList().get(position).get("songPath"));
emailIntent.putExtra(Intent.EXTRA_STREAM,eri);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "hello, it is the recorded file of our conversassion");
emailIntent.putExtra(Intent.EXTRA_STREAM,rlm.getPlayList().get(position).get("songPath") );
RecordedList.this.startActivity(Intent.createChooser(emailIntent, "Send Email"));
I am trying to send an image via an MMS using the following code
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Hi there");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
It opens the Messaging apps and attach the message but it did not write the "sms_body" which is in my case "Hi there". Why?
try this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("subject", "subject");
intent.putExtra("sms_body", "Hi there");
intent.putExtra("address", "Phonenumber");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
intent.setType("image/png");
startActivity(intent);
What seems to be working well is I just added EXTRA_TEXT (a solution which #yasserbn provided in a comment):
intent.putExtra(intent.EXTRA_TEXT, default_message);
in addition to:
intent.putExtra("sms_body", default_message);
And it seems to work whether it gets converted to multimedia message or sent as regular SMS.
I have a requirement that I need to send email from my application, I am using below code to send email...
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("Text/Plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{abc#gmail.com});
intent.putExtra(Intent.EXTRA_TEXT, "hello..");
startActivity(Intent.createChooser(intent, email_chooser_title));
The above code launching the email composer. But after I press on send button , I can see one toast message "Message Sending" , But my message not sent.
pl. help me to figure out where I did wrong in this, or let me know if any alternative to solve this.. thanks.
Intent i = new Intent(Intent.ACTION_SEND);
//i.setType("text/plain"); //use this line for testing in the emulator
i.setType("message/rfc822") ; // use from live device
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"test#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");
i.putExtra(Intent.EXTRA_TEXT,"body goes here");
startActivity(Intent.createChooser(i, "Select email application."));
Im using the following code to send audio-files through email, dropbox +++..
This is not giving me the option to send the same file through MMS..
Anyone know how to attach it to a MMS and let the user send if he/she wants?
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/3gpp");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + aFile));
startActivity(Intent.createChooser(share, "Send file"));
you can used this code..
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("address", "9999999999");
sendIntent.putExtra("sms_body", "if you are sending text");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Downloadtest.3gp");
Uri uri = Uri.fromFile(file1);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("video/3gp");
startActivity(Intent.createChooser(sendIntent, "Send file"));
you have to used your appropriate set type .if audio then audio/*,image then image/png
This code work my samsung nexus,ace 5830 but not working htc amaze.If any one found any solution then please give snippet.