使用此技术不会在电子邮件中发送图像
Image won't be sent in Email with this technique
我想制作我的电子邮件 "parameter-able",这样可以更轻松地处理格式并做一些看起来很专业的事情。
我有这个文件夹:
这是Message.htm的内容:
<html>
<head></head>
<body style='color:grey; font-size:15px;'>
<font face='Helvetica, Arial, sans-serif'>
<div style='position:absolute; height:100px; width:600px; padding:30px;'>
<img src='logo.png' />
</div>
<br />
<br />
<div style='background-color: #ece8d4; width:600px; height:200px; padding:30px; margin-top:30px;'>
<p>Please click the link below to login and get started.</p>
<p>
Username: {0}<br>
Password: {1}<br>
</p>
<br />
<p>Now get lost... cause it's just a test</p>
</div>
</font>
</body>
</html>
然后在我的控制器中,只需使用此 c# 发送它即可:
string body;
using (var sr = new StreamReader(Server.MapPath("\Email\Message.htm") ))
{
body = sr.ReadToEnd();
}
string username = "anto";
string password = "RandomNumber";
string messageBody = string.Format(body, username, password);
EnvoieCourriel("pelletier_antoine@hotmail.com", messageBody, restOfTheParams);
Emial 发送正确。问题 ? <img src='logo.png' />
从未显示。我尝试了很多奇怪的代码。还没有接近成功...
编辑:
我希望图像作为内嵌内容在电子邮件中发送。
更改 HTML
以在 img
标记中包含完整路径:
<html>
<head></head>
<body style='color:grey; font-size:15px;'>
<font face='Helvetica, Arial, sans-serif'>
<div style='position:absolute; height:100px; width:600px; padding:30px;'>
<img src='http://somepath.com/images/logo.png' />
</div>
<br />
<br />
<div style='background-color: #ece8d4; width:600px; height:200px; padding:30px; margin-top:30px;'>
<p>Please click the link below to login and get started.</p>
<p>
Username: {0}<br>
Password: {1}<br>
</p>
<br />
<p>Now get lost... cause it's just a test</p>
</div>
</font>
</body>
</html>
否则接收者将永远看不到该图像。
我想制作我的电子邮件 "parameter-able",这样可以更轻松地处理格式并做一些看起来很专业的事情。
我有这个文件夹:
这是Message.htm的内容:
<html>
<head></head>
<body style='color:grey; font-size:15px;'>
<font face='Helvetica, Arial, sans-serif'>
<div style='position:absolute; height:100px; width:600px; padding:30px;'>
<img src='logo.png' />
</div>
<br />
<br />
<div style='background-color: #ece8d4; width:600px; height:200px; padding:30px; margin-top:30px;'>
<p>Please click the link below to login and get started.</p>
<p>
Username: {0}<br>
Password: {1}<br>
</p>
<br />
<p>Now get lost... cause it's just a test</p>
</div>
</font>
</body>
</html>
然后在我的控制器中,只需使用此 c# 发送它即可:
string body;
using (var sr = new StreamReader(Server.MapPath("\Email\Message.htm") ))
{
body = sr.ReadToEnd();
}
string username = "anto";
string password = "RandomNumber";
string messageBody = string.Format(body, username, password);
EnvoieCourriel("pelletier_antoine@hotmail.com", messageBody, restOfTheParams);
Emial 发送正确。问题 ? <img src='logo.png' />
从未显示。我尝试了很多奇怪的代码。还没有接近成功...
编辑:
我希望图像作为内嵌内容在电子邮件中发送。
更改 HTML
以在 img
标记中包含完整路径:
<html>
<head></head>
<body style='color:grey; font-size:15px;'>
<font face='Helvetica, Arial, sans-serif'>
<div style='position:absolute; height:100px; width:600px; padding:30px;'>
<img src='http://somepath.com/images/logo.png' />
</div>
<br />
<br />
<div style='background-color: #ece8d4; width:600px; height:200px; padding:30px; margin-top:30px;'>
<p>Please click the link below to login and get started.</p>
<p>
Username: {0}<br>
Password: {1}<br>
</p>
<br />
<p>Now get lost... cause it's just a test</p>
</div>
</font>
</body>
</html>
否则接收者将永远看不到该图像。