email share intent android - html styles are not working - android

I tried following code
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
shareEmailSubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml("<b>text to be shared</b><br>link");
but when I send the email, no styles are appearing while
1. sending the email
2. After email is received on desktop email client(eg. gmail)

i tried your code and it is working fine at my end
String body = "<b>text to be shared</b><br>link";
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "hi");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, "Email:"));

The problem which I was facing was due to default android mail client, when I switched to share via gmail, it worked perfectly fine.

Related

How to send an image as email attachment from application?

I'm currently trying to create an app that will take a picture and then attach that picture to an email and send the email.
what i m trying to say
step
1. add recipient Email Address.
2. add Subject.
3. add Some Text.
and Last And Main
4. Attach image from camera and sent that Mail.
I want to send mail from my own application only?? without using any inbuilt Gmail app?
Try below code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
UPDATE
Try this link, it will help you

Email intent always launch gmail by default

String body="message";
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Check out this book I am reading");
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, "Send email..."));
No matter what I do (removing all gmail accounts and signin a hotmail account with mail app), this code launches Gmail by default and do not show or let me choose my universal mail app.
Consequently, there is no way to let user send email via hotmail or other mail provider.
update:
Actually this is the best piece of code I ever come across, it presents you directly with an app chooser where only mail client are present. The answer below will give you a huge list of apps to choose from that are irrelevant.
String mailTo="";
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailTo, null));
email_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here");
email_intent.putExtra(android.content.Intent.EXTRA_TEXT,"Body text here");
startActivity(Intent.createChooser(email_intent, "Send email..."));
Try using the correct MIME type (text/plain) instead of an invalid MIME type (plain/text).

Sending HTML E-mails with Attachment for Android

I'm trying to use this solution but Eclipse still cant resolve "Attachment" and "DataService".
I've imported mail.jar and activation.jar, what could I be doing wrong? I've tried countless other sending email solutions on SO/Google but I couldn't get any of them to work with my attachment and send HTML emails.
Any help would be appreciated.
If you need to construct email to be sent by user manually (open his mail program with new email and attachment) you can use this code:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:" ));
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "MESSAGE");
File toAttach = new File("/path/to/your/file");
Uri uri = Uri.fromFile(toAttach);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(emailIntent);
I used this tutorial and changed
messageBodyPart.setText(_body);
to
messageBodyPart.setContent(_body, "text/html");

how to send image in email body via Android application

i have to sent image via my application in mail body.
but i am unable to see that image in mail editor. it only shows rectangular box with written "OBJ" inside.
thanx.
I am using the following code.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Product:"+ProductComparisonActivity.s_title);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Title:
"+ProductComparisonActivity.s_title+"\n"+"Description:
"+ProductComparisonActivity.s_des+"\n"+"\n"+"Max Price:
"+ProductComparisonActivity.s_max+"\n"+"Min Price:
"+ProductComparisonActivity.s_min+"\n");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<img src="+"\""+ProductComparisonActivity.image_med+";base64,#IMAGEDATA#"+"\">",imgGetter,null));
// emailIntent.putExtra(Intent.EXTRA_STREAM, ProductComparisonActivity.prod_bmp);
emailIntent.setType("text/html");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Sorry, I don't think it is possible.

How do I add a correctly formatted link (with a hash mark) to an email message using intent on Android?

I am creating an email intent and filling the message with a link that contains a hashmark:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http://en.wikipedia.org/wiki/Android_(operating_system)#Software_development");
Once I send this and reopen it on Android, the default mail client only makes the link to http://en.wikipedia.org/wiki/Android_(operating_system)
Is there a way to fix this problem?
This is a problem with Android's default mail. Links work great using the gmail app!
Try the following. I am unable to test my code because of problem in my IDE.
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("http://en.wikipedia.org/wiki/Android_(operating_system)#Software_development"));
Thanks
Deepak

Categories

Resources