使用css发送电子邮件时无法获取CSS [英] unable to get css when sending email with css

查看:149
本文介绍了使用css发送电子邮件时无法获取CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



目前我正在发送电子邮件,但是当我打开时,我可以发送电子邮件gmail它没有捕获htmlpage中包含的css

 < html> 
< head>
< meta charset =utf-8/>
< title>< / title>
< style>
body {
background-color:navy;
颜色:白色;
font-family:Menulis;
margin-left:40px;
}

div {
margin:0 auto;
}

img {
border-radius:5px;
width:200px;
height:300px;
margin-right:200px;
display:block;
float:right;
}

< / style>
< / head>

< body>
< div>
< h1> User {user_email}错误报告< / h1>
< p>当用户尝试从pswrd_recover.aspx页面重置密码

时发生以下错误:< / p>< br />
< img src =https://pcappliancerepair.files.wordpress.com/2016/11
/38644550_m.jpg?w=585\"/>
< p> {error_message}< / p>

< / div>
< / body>
< / html>


解决方案

Gmail删除整个电子邮件的HTML部分。所以,它也会删除任何样式元素。
您需要内嵌CSS,如下所示:

 < body style =background-color:navy;颜色:白色;字型家族:Menulis;保证金左:40像素;> 
< div style =margin:0 auto;> ...< / div>
< img style =border-radius:5px; width:200px; height:300px; margin-right:200px; display:block; float:right; src =https:// .../>
< / body>


is there any way you can send an email from c# asp.net with a html page with css.

Currently I am sending the email but when I open in gmail it does not capture the css included in the htmlpage

<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  <style>
    body{
        background-color:navy;
        color:white;
        font-family:Menulis;
        margin-left:40px;
    }

    div {
        margin:0 auto;
    }

    img{
        border-radius:5px;
        width:200px;
        height:300px;
        margin-right:200px;
        display:block;
        float:right;
    }

 </style>
 </head>

<body>
<div>
    <h1>User {user_email} Error Report</h1>
    <p>The following error occured when user is trying to reset password     

  from pswrd_recover.aspx page:</p><br/>
    <img src="https://pcappliancerepair.files.wordpress.com/2016/11 
 /38644550_m.jpg?w=585"/>
    <p>{error_message}</p>

  </div>
 </body>
 </html>

解决方案

Gmail removes the entire head portion of your email’s HTML. So, it will also remove any style elements. You need to inline your CSS, like this:

<body style="background-color:navy; color:white;font-family:Menulis;margin-left:40px;">
<div style="margin:0 auto;">...</div>
<img style="border-radius:5px;width:200px;height:300px;margin-right:200px;display:block;float:right;" src="https://..." />
</body>

这篇关于使用css发送电子邮件时无法获取CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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