Send E-mail in HTML format - android

I want to send an email in HTML format like as below image.
How can I do this?
Please help me.
Thanks in advance...!

String body = new String("<html><body><table><tr><td><br/>" +header+"</td></tr><br/><br/>"+"Get <b> Best Score </b> in your Android Phone.<br/>"+"" + text_value+ "");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, html.fromHtml(body));
Android support only some Tag..
For more information check below link..
Link1
Link2

Use any html editor program to design the html page. emailText contains the html data. I think this code is fairly obvious.
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
emailTo);
emailIntent.putExtra(android.content.Intent.EXTRA_CC,
emailCc);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
emailText);
this.startActivity(Intent.createChooser(emailIntent, "Choose your email program"));

Related

email share intent android - html styles are not working

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.

Is it possible to send html with the mail intent?

is it possible to send html with the mail intent. I've seen some questions about this, but they are al answered with something like this:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, titleString);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(htmlString));
startActivity(Intent.createChooser(emailIntent, "Email:"));
I'm trying to send some data in a table but the Html.fromHtml will remove my table layout..
Is there any other option to send a html content type email...?
create email body with tags, that are supported by android.text.Html. https://github.com/android/platform_frameworks_base/blob/master/core/java/android/text/Html.java
Solved it by the following work-around:
Create a html file and send it as a attachment..

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