开发者

How to send email newsletter from android application programmatically

I am trying to send an HTML table through em开发者_如何学运维ail, but what i only get is a string with the HTML code. I read about email newsletter a little but i didn't figure out how to make it work in my android test application.

I have a regular table that insert into String string.

String string = "<table border='1' align='center'><tr style='color:blue'><th>Day</th><th>Date</th><th>Start Time</th><th>End Time</th><th>Total Time</th></tr><tr><td align='center'>Sunday</td><td align='center'>19/07/2011</td><td align='center'>13:00</td><td align='center'>19:00</td><td align='center'>06:00</td></tr></table>";    
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, getSenderList());
intent.putExtra(Intent.EXTRA_SUBJECT, mContext.getText(R.string.app_name));
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(string));
mContext.startActivity(intent);

Someone can please point me how to do that?

Thanks


Check out the following question: Send HTML mail using Android intent.

If you want to use the default mailer, change your code to the following:

    String body = "<table border='1' align='center'><tr style='color:blue'><th>Day</th><th>Date</th><th>Start Time</th><th>End Time</th><th>Total Time</th></tr><tr><td align='center'>Sunday</td><td align='center'>19/07/2011</td><td align='center'>13:00</td><td align='center'>19:00</td><td align='center'>06:00</td></tr></table>";

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:" + getSenderList()));
    intent.setType("text/html");
    intent.putExtra(Intent.EXTRA_SUBJECT, mContext.getText(R.string.app_name));
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
    mContext.startActivity(intent);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜