简体   繁体   English

在href mailto链接中设置正文文本

[英]Styling body text in a href mailto link

I have an hyperlink which has a mailto link and I am specifying the subject and body text in the hyperlink itself. 我有一个带有mailto链接的超链接,我在超链接本身中指定主题和正文。 So when the user clicks on the hyperlink, his default email client application will be opened with the To, Subject and body text pre-populated in it. 因此,当用户单击超链接时,将打开其默认电子邮件客户端应用程序,其中预先填充了“收件人”,“主题”和正文。

I want to know how I can apply css formatting technique in the body text of it something like font names, font color etc. 我想知道如何在它的body应用css格式化技术,比如font名称, font color等。

Can anyone give me any idea on this? 任何人都可以对此有任何想法吗?

 <!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> 

On clicking the email hyperlink, the below message will be shown in the email content. 单击电子邮件超链接时,以下消息将显示在电子邮件内容中。

样品

I want to apply css formatting to the content highlighted in the red box. 我想将CSS格式应用于红色框中突出显示的内容。

You can't change/modify CSS of a mail client through a <a href="mail to:mail@example.com"></a> . 您无法通过<a href="mail to:mail@example.com"></a>更改/修改邮件客户端的CSS。

They have their own CSS styles and this would be a security issue 他们有自己的CSS样式,这将是一个安全问题

Expanding on Dippas' answer... 扩大Dippas的回答......

According to the Mailto specification , you can add whatever arbitrary headers you want to your mailto link. 根据Mailto规范 ,您可以向mailto链接添加任何您想要的任意标头。 This means you could add &Content-Type=text/html to the url to indicate it's an HTML message, in which case it should parse your HTML and CSS like a normal HTML email. 这意味着您可以将&Content-Type=text/html到网址以指示它是HTML消息,在这种情况下,它应该像普通的HTML电子邮件一样解析HTML和CSS。

However the spec also states that the only headers that should be relied upon are the subject and body headers. 但是规范还指出,唯一应该依赖的标题是主题和正文标题。

The creator of a mailto URL cannot expect the resolver of a URL to understand more than the "subject" and "body" headers. mailto URL的创建者不能指望URL的解析器比“subject”和“body”头更容易理解。 Clients that resolve mailto URLs into mail messages should be able to correctly create RFC 822-compliant mail messages using the "subject" and "body" headers. 将mailto URL解析为邮件消息的客户端应该能够使用“subject”和“body”标头正确创建符合RFC 822的邮件消息。

In other words, you can try it, but don't expect it to work for everyone. 换句话说,您可以尝试它,但不要指望它适用于每个人。 If this is for public use, just forget about it, stick to plaintext. 如果这是供公众使用,请忘记它,坚持使用明文。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM