image not displaying while sending mail through asp.net application

Posted by Ankitsrist under ASP.NET on 2/22/2013 | Points: 10 | Views : 1570 | Status : [Member] | Replies : 4
image not displaying while sending mail through my app i have used external html file below is my code
  StreamReader reader = new StreamReader(Server.MapPath("~/HTMLPage.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
myString = myString.Replace("$$Admin$$", "ankit");
myString = myString.Replace("$$CompanyName$$", "cnet infotech");

MailMessage msg = new MailMessage();
msg.From = new MailAddress("ankitsaxena22@rediffmail.com");
msg.To.Add("ankitsaxena2011@india.com");
msg.Subject = "appy budday";

msg.Body = myString.ToString();
msg.IsBodyHtml = true;
SmtpClient smtp=new SmtpClient();
smtp.Host ="smtp.gmail.com";
smtp.Port=587;
smtp.Credentials =new System.Net .NetworkCredential("", "");
smtp.EnableSsl =true ;
smtp.Send(msg);

html file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Happy Birthday</title>
</head>
<body >
<img src="~\Sunset.jpg" alt="wishes" height ="300" width ="300"/>
<div style = "border-top:3px solid #EB5E00">&nbsp;</div>
<table >
<tr>
<td><b><span style = "font-family:Arial;font-size:10pt">Dear:</span></b></td>
<td>$$Admin$$</td>
</tr>
<tr>
<td><b><span style = "font-family:Arial;font-size:10pt">CompanyName:</span></b></td>
<td>$$CompanyName$$</td>
</tr>
</table>
</body>
</html>





Responses

Posted by: Vuyiswamb on: 2/22/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
This path does not look correct

Instead of

src="~\Sunset.jpg"


try

src="~/Sunset.jpg"


or simply

src="Sunset.jpg"


Thank you for posting at Dotnetfunda
[Administrator]

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 2/22/2013 [Member] Starter | Points: 25

Up
0
Down
thanks sir for your reply but sir still image is not appearing...please help

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/23/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
send me a Screenshot of your solution Explorer so that i can see the image where is sitting in the structure of your Project

Thank you for posting at Dotnetfunda
[Administrator]

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 2/23/2013 [Member] Starter | Points: 25

Up
0
Down
i have attached my solution expl.
 Download source file

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response