简体   繁体   English

如何将CSS应用于Android中的电子邮件正文文本?

[英]How to apply CSS to email body text in Android?

I am sending an email through intent, here I want to set CSS styles to the body of email, I have already referred many questions and answers on Stack and found below code: 我正在通过意图发送电子邮件,这里我想将CSS样式设置为电子邮件正文,我已经在Stack上提到了很多问题和答案,并在下面的代码中找到:

Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/html");
                intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"me@mydomain.com"});
                intent.putExtra(Intent.EXTRA_SUBJECT, "I would like to buy the following");
                intent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
                startActivity(Intent.createChooser(intent, "sending mail"));

but this code sets only text in email body and skips my css styles, how do I achieve that? 但是这段代码只设置了电子邮件正文中的文本并跳过了我的css样式,我该如何实现呢? I want to set background color, text size, text color to the email body all through Android intent. 我想通过Android意图将背景颜色,文本大小,文本颜色设置到电子邮件正文中。

Found an answer on this SO post, according to this gmail doesn't support css in Head and Body tag in html. 在这个SO帖子上找到了答案,根据这个gmail不支持html中Head和Body标签中的css。

Also see this link for more about Css support in browsers. 另请参阅链接以获取有关浏览器中Css支持的更多信息。

save the html as a file and add your css html attachment to a list of Uri objects and add this line:- 将html保存为文件并将您的css html附件添加到Uri对象列表中并添加以下行: -

intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android-如何将文本格式设置为电子邮件客户端的电子邮件正文中的表格 - android - How to format the text as table in email body of email client 如何设置(CSS)由Android应用程序(Intent)创建的电子邮件的HTML正文? - How to style (CSS) the HTML body of an email, created by an Android application (Intent)? 如何在 android 中获取 email 的内容,如 Email ID、主题、消息正文和附件? - How to get content of email like as Email ID ,Subject ,Message body text,and Attachment in android? 在android或ios中发送具有CSS样式的正文的电子邮件 - send email with body having css style in android or ios 如何在Android电子邮件正文中发送图像 - How to send image in email body Android 如何在Android的电子邮件正文中使用HTML标签或将正文加粗显示标题? - How to use HTML tag in Email Body in android or to bold Title of body? 如何在Android电子邮件应用程序中附加电子邮件正文中的3个字段 - How to attach 3 fields in email body in an android email application 在Android中的电子邮件中添加正文 - Adding the Body in the Email in Android Android,如何将CSS应用到WebView中? - Android, How can I apply CSS into WebView? 从Xamarin.Android App添加电子邮件正文文本并发送电子邮件 - Add Email Body Text and Send Email from Xamarin.Android App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM