在a href mailto链接中设置正文样式

8
我有一个超链接,其中包含一个mailto链接,并在超链接本身中指定主题和正文文本。因此,当用户单击超链接时,他的默认电子邮件客户端应用程序将打开,并预填充To、Subject和正文文本。
我想知道如何在其中应用CSS格式化技术,例如font名称、font color等等。
有人能给我任何想法吗?

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Unauthorized access</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
    </head>
    <body class="skin-blue">
        <!-- header logo: style can be found in header.less -->
        <div>
            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side" style="margin-left:0">
                <section class="content">
                    <div class="error-page" style="margin: 0">
                        <div class="error-content" style="width:100%">
                            <h3><i class="fa fa-warning text-yellow"></i> You are not authorized to view the content.</h3>       <br>
                            <p style="width:75%; text-align:center;margin-left:15%">
                                Please make sure you have the access to the server or contact support team at <a href="mailto:username@domain.com?subject=Unable&nbsp;to&nbsp;access&nbsp;server&body=Hi,%0D%0A%0D%0AMy&nbsp;user&nbsp;account&nbsp;does&nbsp;not&nbsp;have&nbsp;access&nbsp;for&nbsp;the&nbsp;server.%0D%0A%0D%0ARequest&nbsp;you&nbsp;to&nbsp;kindly&nbsp;provide&nbsp;access&nbsp;to&nbsp;server.">username@domain.com</a>.
                            </p>
                        </div><!-- /.error-content -->
                    </div><!-- /.error-page -->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
    </body>
</html>

当单击电子邮件超链接时,下面的消息将显示在电子邮件内容中。

示例

我想对红色框中突出显示的内容应用CSS格式。


2
你能展示一下你的代码吗?如果你能创建一个fiddle,那就太好了。 - Lucian
你只能使用内联样式。这意味着你的链接样式表是不起作用的。举个例子,<aside class="right-side" style="margin-left:0"> 将变成 <aside style="float: right; margin-left: 0">。即使如此,也可能不起作用,因为每个客户端都有自己的样式,你需要用内联样式覆盖它们。 - Marin N.
2个回答

3

您无法通过 <a href="mail to:mail@example.com"></a> 更改/修改邮件客户端的CSS。

它们有自己的CSS样式,这会带来安全问题。


“它们有自己的CSS样式”是什么意思?肯定有一些共同的标准,因为我能够发送彩色邮件,在许多客户端中正确接收。” - croraf

3
扩展Dippas的答案...
根据Mailto规范,您可以向您的mailto链接添加任意标题。这意味着您可以在url中添加&Content-Type=text/html以指示它是一条HTML消息,在这种情况下,它应该像普通HTML电子邮件一样解析您的HTML和CSS。
但是规范还说明,应仅依赖于主题和正文标题。
引用:
“mailto URL的创建者不能指望URL的解析器理解更多内容   除了“主题”和“正文”标题之外。客户端   将mailto URL解析为邮件消息时应能够正确地   使用“主题”和“正文”标题创建符合RFC 822的邮件消息。”
换句话说,您可以尝试它,但不要期望它适用于每个人。如果这是针对公众使用,请忘记它,坚持使用纯文本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接