Reputation: 3316
I'm looking to make my email "parameter-able" so it's easier to work with format and do something that looks professional.
I have this folder :
This is the content of the 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>
Then in my controller, simply send it using this 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("[email protected]", messageBody, restOfTheParams);
Emial is sent correctly. The problem ? <img src='logo.png' />
is never showing. I tried a LOT of weird codes. Not been close to success yet...
EDIT :
I want the Image to be sent INSIDE the email, as inline content.
Upvotes: 0
Views: 36
Reputation: 883
Change the HTML
to have a full path in the img
tag:
<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>
Otherwise the receiver will never see that image.
Upvotes: 1