views:

760

answers:

3

hi friends... i have generated an html code(complete with tags) as a String... now i want to send this html code as a html to mail... my code is as below..

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
intent.putExtra(Intent.EXTRA_SUBJECT, "I would like to buy the following");
intent.putExtra(Intent.EXTRA_TEXT, purchaseOrder());
startActivity(Intent.createChooser(intent, "sending mail"));

where the purchaseOrder() is the method which passes me the string having full html code... but though the gmail client opens on my nexus1 but it has the String with all html tags and not the actual html view... i tried the following but got error... The gmail crashed...

intent.putExtra(Intent.EXTRA_STREAM, purchaseOrder());

Can any1 plz help...

Thanx

A: 

Convert your string to html Spannable text. for that refer this package.

Praveen Chandrasekaran
can u plz explain with a small example?? i mean though i converted the string to SpannableString... do i need to convert it to html too or will the intent take the SpannableString and convert it to html automatically.. thanx 4 ur suggestion...
JaVadid
JaVadid
i didnt work on it. just i had give a suggestion to you. i gonna search about it.if i found an answer then let u know.
Praveen Chandrasekaran
can you show your PurchaseOrder() method?
Praveen Chandrasekaran
check this link http://developer.android.com/intl/zh-CN/guide/topics/resources/available-resources.html topic name: Using Styled Text as a Format String
Praveen Chandrasekaran
thanx buddy, but couldnt find anything useful on the link... do let me know if u find something useful...
JaVadid
check the APIDEMOS/Text/linkify example code. Html.fromHtml(pass ur string); just try this.
Praveen Chandrasekaran
A: 

OK Guys i stopped working on this topic long back! Somehow i tried and tried but couldnt get to make it work! I stopped my research and used Php as a medium to send formatted email as attachment!

Thanx for your help Praveen!

JaVadid
+1  A: 

For anyone else looking to do this, sending the email manually behind the scenes using android-javamailer works (I've done it):

http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android

mdaddy