I want to attach amr file in attachment but i am unable to attach.
My code is as follows:
Intent emailIntent = new Intent(
Intent.ACTION_SEND);
Uri U = Uri.parse(path of amr file);
//System.out.println("uri is:" + U);
emailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "" });
emailIntent.putExtra(
android.content.Intent.EXTRA_SUBJECT,
" from ..");
emailIntent.putExtra(
android.content.Intent.EXTRA_TEXT, ""
+ "\n" + "\n" + "Through application name");
emailIntent.setType("audio/rfc822");
//emailIntent.setType("audio/*");
// emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,U);
emailIntent.putExtra(Intent.EXTRA_STREAM, U);
startActivity(Intent.createChooser(emailIntent,
""));
i have used emailIntent.setType("audio/rfc822") , emailIntent.setType("audio/*"); and emailIntent.setType("audio/amr"); but no luck
Any help will be appreciated.
have you tried using,
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
Activity Action: Deliver multiple data to someone else.
Related
I am trying to attach a text file in order to send it with an email
but whenever i open the Email app it says that the file does not exist Help Please
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"musabyahya1005#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(directory+"/data.txt"));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getBaseContext(), "An Error Happened ", Toast.LENGTH_SHORT).show();
}
If you are trying to send files with email, make sure that they are on a public accessible location and that you tell it that it is a file you want to send. Use this code as an example.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("message/rfc822").putExtra(Intent.EXTRA_EMAIL, new String[]{"fake#example.com"}).putExtra(android.content.Intent.EXTRA_SUBJECT, "Mail subject").putExtra(android.content.Intent.EXTRA_TEXT, "lalalala");
String targetFilePath = Environment.getExternalStorageDirectory().getPath() + File.separator + "tmp" + File.separator + "test.txt";
Uri attachmentUri = Uri.parse(targetFilePath);
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://" + attachmentUri));
i want to send .apk file from sdcard via email intent but not getting attachment.
see below codei try this code but not working for me..
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "email id" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"go on read the emails");
Log.v(getClass().getSimpleName(),
"sPhotoUri=" + Uri.parse("file:/" + "/sdcard/obb/rr.apk"));
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:/" + "/sdcard/obb/rr.apk"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
This code says could not attachment and not getting mail.
Try to change the type of your attachment as below:
emailIntent.setType("application/zip");
thanks for help i got the mail using this one.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"email id"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App new 1");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/rr.apk"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Don't use hard coded /sdcard/ there is no guarantee that the SD card will have that path
Instead change
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:/" + "/sdcard/obb/rr.apk"));
to
Uri fileUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separatorChar + "obb" + File.separatorChar + "rr.apk"));
emailIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
Also change
emailIntent.setType("text/plain");
to
emailIntent.setType("application/zip");
I am sending a mail by using below code and i need to send a .text file also using gmail only.
How can i do it? Please can any one help me?
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("") +
"?subject=" + Uri.encode("Sample Text") +
"&body=" + Uri.encode("Hi");
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Send mail..."));
Thanking in Advance.
File sd = Environment.getExternalStorageDirectory();
File fileDir= new File(sd, "dir_path");
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileDir.getAbsolutePath() + "/"
+ FILE_TXT
startActivity(Intent.createChooser(email , "Email: Text File"));
Hi i am developing an android application with email functionality. Here i need to send a CSV file from my path data/data/mypackage/files folder. I am storing the csv file there.It is saving there good.My csv file size is just 245 bytes only. But when i tried to send that file throught mail functionality of android is displaying "File too Large to attach.." message is displaying.
Here is my code:
String filelocation="file:///data/data/my package/files/excerDB.zip";
final Intent emailIntent = new
Intent(android.content.Intent.ACTION_SEND);
emailIntent .setType("plain/text");
emailIntent .putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"purpletalk.raghu#gmail.com"});
emailIntent .putExtra(android.content.Intent.EXTRA_SUBJECT, "Attendence Report");
emailIntent .putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(filelocation));
startActivity( emailIntent);
But it is not working for me. Please advice me how can i send my file as a attachment to mail in my application.
i hope this code will help u
String FILE = Environment.getExternalStorageDirectory() + File.separator
+ "Foldername";
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
// sendIntent.setType("text/html");
sendIntent.setType("application/csv");
sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "");
sendIntent.putExtra(Intent.EXTRA_TEXT, "");
String temp_path = FILE + "/" + "Filename.csv";
File F = new File(temp_path);
Uri U = Uri.fromFile(F);
sendIntent.putExtra(Intent.EXTRA_STREAM, U);
startActivity(Intent.createChooser(sendIntent, "Send Mail"));
Enjoy this code!
I want the user to be able to send an email from inside my android app, so I have
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,message);
startActivity(emailIntent);
but I don't know what I need to do if I want to have 2 .png images attached to this email also.
Thanks,
Try out this one.
But for me it is only working on a real device.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
emailIntent.setType("image/png");
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.file1));
uris.add(Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.file2));
emailIntent.putExtra(Intent.EXTRA_STREAM, uris));
startActivity(emailIntent);
Try this:
Intent iShare;
iShare = new Intent(Intent.ACTION_SEND);
iShare.setType("image/png");
//below you trying to send the images path it always doens have to be a
//image in the drawable u can get the captured image or in the gallery :)
iShare.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+fn.getPath()));
i.putExtra(Intent.EXTRA_TEXT, "Username: " + usernames + "\nClinic Number: " + clnumber + "\nClinic Name: " + clname + "\nBranch: " + spnnr);
startActivity(Intent.createChooser(iShare, "Share"));
try {
startActivity(Intent.createChooser(ishare, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(secondpage.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}