Email View doesn't show interpreted HTML - android

I want compile an email with HTML content which users can see before send it.
I use an
Intent email = new Intent(Intent.ACTION_VIEW);
But I cannot see an HTML interpreted, see the image below:
There is a way to show an HTML interpreted email content?
Thanks a lot

you have to set type for intent :see this method:http://developer.android.com/reference/android/content/Intent.html#setType%28java.lang.String%29
you ahve to add also this line for it shows like html for ur data:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));**strong text**

Related

How to pass hyperlink to Gmail in Intent ACTION_SEND?

May be this question is already asked or duplicate of another question, but I didn't get any solution for my search.
Here are the links which I followed for my question:
Link1 Link2
Actually, my question is related to sharing HTML text in android default intent with an ACTION_SEND. When I am trying to create a hyperlink to URL with different value then it is showing a simple text of value. That is not clickable as a link.
Here is how I am doing:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
String link = "https://www.android.com/";
String linkValue = "Click Me";
String body1 = "" + link+ "";//I don't want this
String body2 = "" + linkValue + "";//This is not working
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body2));
startActivity(Intent.createChooser(intent, "Share With"));
For body2:
When I share the text using Gmail then in email hyperlinked text will come as a normal text. Simply "Click Me". I checked it on desktop browser also. But there also it is same. I checked this text in Inspect Element(You can get Inspect Element of a browser page like: Right click on browser page>> In popup window click at the bottom Inspect OR refer Inspect Element) format and found there was no tag for hyperlink text.
For body1:
It's working and I got the URL as a hyperlink in the email, but I got the URL as a hyperlink I don't want to show the same URL in email rather than there should be some hint value as body2 format. This format can be achieved by direct URL sharing in the body no need of tag.
So finally my search is, Is there any way in Android for sharing hyperlink text with different hint value rather than as of link(URL).
I suggest you use a string resource instead of a Java string, it's generally and good practice and that way you won't have to escape the " either. And with the HTML data you'll have to wrap it in CDATA.
XML:
<string name="readyandroid"><![CDATA[readyandroid]]></string>
in Java, replace body2 with:
String body2 = getString(R.string.readyandroid);
Then try passing it to the intent and sending it in an email, it should be a proper hyperlink as you would like it to be.
What you do in body is perfectly correct.
But Gmail reads the extra android.intent.extra.TEXTas a string.
You are in fact making a feature request / reporting a bug.
android:autoLink="web|email"
Please add this code in textview xml. It will directly goes gmail link
I don't think you can do using email Intent. Send email without intent Make email client for sending email. That will support HTML tag.
plz refer
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android
After you put your String to extra, it lose it attributes as Spanned. If you would send it as html, it can be resolved by some applications and shown as you want. Generally, you just put a plain text into the Bundle of your Intent, and each application interprets it as it wish, so there is no solution to send it as html and force applications to show it as html.
On the other hand, if you know which applications you're going to use via share, you can read its documentation and check if it allows to send hyperlinks via ACTION_SEND intent.
You can tell a receiver that a type of your text by intent.setType("text/html"), maybe some applications behavior depends on it.
Yes, I achieved this issue solution. Thanks, #Faraz.
This is my answer code, as I created tag string in string.xml
<string name="link_to_google_map"><![CDATA[LINK TO GOOGLE MAP]]></string>
And my code is like this, which works perfectly for sharing using tag in android:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
String shareText = "Thank you for using the ReadyAndroid App" + "<br />" + "Name : " + "ReadyAndroid";
shareText += "<br />" + "Address : " + "https://readyandroid.wordpress.com/ <br />Mandawa, Jhunjhunu, Rajasthan 333704";
String mapLocation = String.format(getString(R.string.link_to_google_map), 28.0500, 75.1487);
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(shareText+mapLocation));
startActivity(Intent.createChooser(intent, "Share with"));

Android: Send HTML text using ACTION_SEND Intent

I'm trying to send some HTML formatted text via the ACION_SEND Intent in my app. The HTML file is located in my assets directory and it has links to some images and contains other CSS stylings. Thus far I've tried the following:
private Intent getEmailIntent(String deepLink) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
// sharingIntent.setType("text/html");
sharingIntent.setType("text/plain");
// sharingIntent.setType("message/rfc822");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getShareSubject());
sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(getHtmlTextFromAssetsFile("myHtml.html")));
return sharingIntent;
}
As you can see from the above method, I've tried using all three of the IntentTypes in the code, without success.
The HTML file has CSS within a <style> tag , and that is not applied. It just shows up as plain text in all cases. No images (remotely located) are loaded. And </br> tags are ignored.
Has anyone worked with this? How can I get my app to send such an email? Any pointers would be helpful.
Probably not many email clients on Android support HTML. What you can do is providing plain text in EXTRA_TEXT and putting the HTML in EXTRA_HTML_TEXT as documented here: https://developer.android.com/reference/android/content/Intent.html#ACTION_SEND

Android: prefilled email with html

i have this code which prefill an email and throw an intent:
Intent email_intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
email_intent.putExtra(Intent.EXTRA_SUBJECT,
"iTempco"+getString(R.string.superficie_scambio));
email_intent.putExtra(Intent.EXTRA_TEXT,{{here_the_html_code}});
email_intent.setType("text/html");
startActivity(email_intent);
where you see {{here_the_html_code}} i have a string with html code (working perfectly).
the problem is that, when the activity is thrown, i see the html code (the source) in the text area of the client, not the "converted one"
how can i?
thanks.
I had the same problem, but couldnt solve it.
Most of the default email client won't handle the html tags.
The best workaround i found is sending the html as a attachement.
check my question about this:
Is it possible to send html with the mail intent?

android : email with templates

I am sending emails from my application.
I want to know if there is a way to define templates for eg :
subject: Regarding {{title}}
Body: You may be interested in the product {{title}} \b {{desc}}
I would like to define this templates in some resource file.
Thanks for your help and time.
Just construct mailto URL in accordance with RFC-2368, which includes subject and other fields. So in the end you'll have URI which can be used to start email sender activity:
Uri uri=Uri.parse("mailto:example#example.com?subject=Here goes test message");
intent = new Intent(Intent.ACTION_SENDTO, uri);
activity.startActivity(intent);
Futhero you can programmatically construct mailto URL as you want
You can put in strings.xml w/ string format character like %d %s %f..., and make use of String.format().
It's nice if others have better ideas :)

Embedding image in email in Android

Is it possible to programatically embed an image in the body of an email sent by the Mail app in Android?
Can I use the ACTION_SEND intent to do this, or should I compose the email myself?
to put the image in the body, you need to set the content type to "text/html" and then put an img tag in the email body. if you don't want to use a webserver to host the image, then you can use a data uri for the image.
Info & Sample:
<img src="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" />
If you want to attach an image to the email, you use the putExtra method and set it to EXTRA_STREAM.
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, myImageStream);
If your image (or file) is in the SD card, you can proceed as follow:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/your_path_in_the_sd_card/your_image.png"));
startActivity(shareIntent);
If you don't want to send image, you need to modify the MIME in the "setType()" method.
For more details check this post.

Categories

Resources