1

In my application I have to use a some HTML stuff in a string. But HTML is not working as intended. I have to use that string (Text) to send as an email. The sequence I required of HTML is:

Title (in the center)

Image (in the center)

Description (left align)

and then this HTML string is passed to an email intent. But neither image is showing up in the email nor the title text is getting center align. This is how I am doing this all:

        Intent it = new Intent(Intent.ACTION_SEND);
        it.putExtra(Intent.EXTRA_EMAIL, "");
        it.setType("text/html");
        String title = title;
        String emailText = emailText;   
        it.putExtra(Intent.EXTRA_SUBJECT, title);
        it.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(emailText));
        this.startActivity(it);

and this is how the emailText is being formed:

 emailText = "<p style= 'color:#000000; font:Georgia; font-size:18pt; text-align:center' align = 'center'><b>" + title +" </b></p>"
             +"<br/><br />"
             +"<img style=\"border:3px solid #173E8C\" src=\'" +imageUrl+"\' width=\"120\" height=\"90\"align=\"center\"/>"
             +"<br/><br/>"
             +"<p>" + description;

But I am unable to get the required result that I have mentioned right at the top, Any help is appreciated related to the issue. Thanks in advance..:-)

2
  • Try doing, this line "<img style=\"border:3px solid #173E8C\" src=\'" +imageUrl+"\' width=\"120\" height=\"90\"align=\"center\"/>" should look like this "<img style='border:3px solid #173E8C' src='" +imageUrl+"' width='120' height='90'align='center'/>" Commented Jul 11, 2012 at 11:43
  • I tried the same in first attempt...it did not worked..to confirm I have tried it again but no luck... Commented Jul 11, 2012 at 11:48

2 Answers 2

1

You must specify the type of email through the function setType () :

it.setType("text/html");  // for HTML
it.setType("text/plain"); // for plain text
Sign up to request clarification or add additional context in comments.

3 Comments

try this before Html.fromHtml() : TextUtils.htmlEncode(emailText)
What is the intent of targeted email? AOSP email, Gmail or email client manufacturer (HTC, ...)?
It's Gmail...I have used Email client too...but it also did not show the image
0

You can't send a image as email body in android through Intent.

5 Comments

image being sent is wrapped in an html string.
see the accepted answer in this link. You will get the reason. stackoverflow.com/questions/5244472/how-add-image-in-email-body
Yes I have gone through this thread...but isn't there any other way to do so..???? Or it's a clear straight "No"..????
yes, there is no possible ways. I have also tired, results in vain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.