Is it possible to send html with the mail intent? - android

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..

Related

base64 not display in image tag for email in android

I have one html to display image as base64 :
<html><body>hello<br/><img style='display:block; width:100px;height:50px;' id='base64image' src='data:image/png;base64,<!-base 64 string-->' /></body></html>
the result is this:
but when i use this in Email like this:
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.setType("text/html");
String body = new String("<html><body>hello<br/><img style='display:block; width:100px;height:50px;' id='base64image' src='data:image/png;base64,<!-base 64 string-->' /></body></html>");
email.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(email,"Choose an Email client :"));
The result is like below:
image is not display in mail. is there something that I am missing here. is there any limit to pass the base64 data or something other issue is here?.
Not sure if this would work but try using this
email.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
insted of
email.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
Unfortunately, it's not possible to do this with Intents.
The reason why for example bold text is displayed in the EditText and
not an Image is that StyleSplan is implementing Parcelable whereas
ImageSpan does not. So when the Intent.EXTRA_TEXT is retrieved in the
new Activity the ImageSpan will fail to unparcel and therefor not be
part of the style appended to the EditText.
Using other methods where you don't pass the data with the Intent is
unfortunately not possible here as you're not in control of the
receiving Activity.
I search lot for this issue and i found a very good answer at this link :
https://stackoverflow.com/a/7550813/1186689
It gives the answer and also clear all doubts.

How to send html content with image through android default email client?

How can we get inline images in default email client for android through Hypertext Markup Language (HTML) ?
You can not. As default Email application's doesn't support <img /> tag.
Because, ImageSpan doesn't implementing Parcelable.
Hence its failed with Intent's PUT_EXTRA.
Its works only for basic tags, like, <b>, <i> ..etc
Look at Sending html email in android using <table>, etc. - is there really no relatively built-in Intent way? and How to show an image in the email body?
String body ="<html><body><table>...</table></body></html>";
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(body).toString());
startActivity(Intent.createChooser(emailIntent, "Email:"));
Unfortunately, the <table> ,'img' tag isn't supported. Supported tags are actually more dependent on the email client you use to send the email - some of them are more finicky/restrictive than others. Most of them use the super-basic formatting tags like <b>, <i>, <h1>, and so on, though.

Send Email in Android using the default android app(Builtin Email application)

I want to send email from my application using the default android email app. I have written a code for that as
Intent mailIntent = new Intent(android.content.Intent.ACTION_SEND);
mailIntent.setType("plain/text");
mailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { EMAIL });
mailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Invitation");
mailIntent.putExtra(android.content.Intent.EXTRA_TEXT,MAIL_MESSAGE);
startActivity(mailIntent);
But here it is opening the email application. I want to send the mail instead of starting any activity. Is there any ways to replace the startActivity and initiate the intent action?
Please help me.
Thanks in advance.
this link can be useful, have a look at another useful link or a code snippet from this link is attached below
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, newString[]{"yourmail#website.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mySubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, myBodyText);
startActivity(Intent.createChooser(emailIntent, "Send mail));
Hope that helps...
yes you can done it by configuring the mail code on server side and from android call web service then server will send the mail
http://fahmirahman.wordpress.com/2011/04/21/connection-between-php-server-and-android-client-using-http-and-json/

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

Send E-mail in HTML format

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"));

Categories

Resources