有什么方法可以从 c# asp.net 发送带有 html 页面和 css 的电子邮件。
目前我正在发送电子邮件,但是当我在 gmail 中打开时,它没有捕获 html 页面中包含的 css
<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 会删除电子邮件 HTML 的整个标题部分。因此,它还会删除任何 style 元素。 您需要像这样内联您的 CSS:
<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>
关于c# - 使用 css 发送电子邮件时无法获取 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44711461/