在Android中发送HTML格式的电子邮件 [英] Sending HTML formatted email in Android

查看:191
本文介绍了在Android中发送HTML格式的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功创建了一个Android应用程序,该应用程序可以计算价格,然后能够以预格式化的方式将该数据传输到用户选择的电子邮件程序中。根据用户在应用程序中创建的数据,将包含HTML的字符串读入意图。我为此使用的代码是:

I have successfully created an Android app that calculates prices and then is able to transfer that data in a preformatted fashion to an email program of the users choice. Depending upon the data the user creates in the app, a string containing the HTML is read into an intent. The code I have for this is:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(emailText));
QuoteDroid.this.startActivity(emailIntent);

这很好,电子邮件为 主要 格式正确,并且通常发送 主要 正确。我的问题是,出于商业目的,我必须从非Gmail帐户发送它。当我在电话上选择通用电子邮件应用程序时,它无法正确处理HTML,当我发送电子邮件时,它以纯文本格式设置。

This is all fine and the email is mostly formated correct when I choose the Gmail app, and generally sends mostly correct. The issue I have with this is that I must send it from a non-gmail account for business purposes. When I choose the generic email app on the phone it does not process the HTML properly and when I send the email it is formated in plain text.

我已经阅读了无数的文章和论坛帖子,但无济于事。如何处理包含HTML的字符串,以使收件人在使用内置电子邮件应用程序发送电子邮件之后可以正确地格式化电子邮件?

I've read through countless articles and forum posts, but to no avail. How do I process the string, containing the HTML, in such a way that the email -after being sent with the built in email app- is viewed properly formated by the receiver?

推荐答案

要由单个邮件应用程序正确处理它作为EXTRA_TEXT收到的字符串。行为良好的邮件应用程序将看到模仿类型并适当处理EXTRA_TEXT,但并非所有邮件应用程序都可以。

It's up to the individual mail app to properly handle the String that it receives as the EXTRA_TEXT. A well-behaved mail app will see the mimetype and handle the EXTRA_TEXT appropriately, but not all mail apps do.

这篇关于在Android中发送HTML格式的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆