How to send image to html formatted email address in android?

I want to send html formatted email, although my application but the styles for all tags are not supported when sending email.

here is my Java code:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Look What I Found!");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
      Html.fromHtml(mMessage)
);
startActivity(emailIntent);`

      

Here is my html that I want to send:

"<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <center> <table style="width: 600px; margin:0 auto" cellpadding="0" cellspacing="0"> <tr> <td> <table> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/header-600x123.jpg" alt="Churchill Downs" style="display: block;width: 600px;height: 123px;">	</td> </tr> </table> <table style="padding:40px 0px;"> <tr> <td style="width: 50px;"> </td> <td> <p style="font-family: 'Open Sans', Helvetica, Arial, sans-serf;text-align: justify; font-style: 14px;">View this shared article from the Churchill Downs Incorporated Magazine $title. Download the official lifestyle app of Churchill Downs – "Club 1875" to access the elegant world of Thoroughbred racing and the Kentucky Derby. Stay up to date on fashion, food, celebrities and some of the most recognizable names in the industry. Club 1875 is your behind the scenes guide to the most exciting two minutes in sports – whether you’re at the track or far away! </p> </td> <td style="width: 50px;"> </td> </tr> </table> <center> <table> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/logo-235x98-02.jpg" alt="" style="display: block; width: 235px; height: 98px;" alt="CLUB 1875"> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="https://itunes.apple.com/us/app/club-1875/id1171549047?mt=8" target="_blank"><img src="https://www.twinspires.com/sites/twinspires.com/files/icon-148x40-02.jpg" alt="Download Here" style="display: block;width:148px;height: 40px; "></a> </td> </tr> </table> </center> <center> <table style="padding-top: 40px;"> <tr> <td> <img src="https://www.twinspires.com/sites/twinspires.com/files/footer-558x278.jpg" style="display: block;width: 558px;height: 278px;" a"
      

Run codeHide result


And here is the output when I send the email:

enter image description here

+3


source to share


1 answer


Try it.



String mailId="yourmail@gmail.com";
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailId, null)); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject text here"); 
// you can use simple text like this
// emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Body text here"); 
// or get fancy with HTML like this
emailIntent.putExtra(
         Intent.EXTRA_TEXT,
         Html.fromHtml(new StringBuilder()
             .append("<p><b>Some Content</b></p>")
         .append("<a>http://www.google.com</a>")
         .append("<small><p>More content</p></small>")
         .toString())
     );
startActivity(Intent.createChooser(emailIntent, "Send email..."));

      

+1


source







All Articles