0
message.Body = "Dear " + myds.Tables[0].Rows[0].Field<string>("C_Name").ToString() 
+ " <br /> <br /> Your Registrtion is Successfull...<br/><br/>
<table  border='4'><tr><td>Name = " 
+ myds.Tables[0].Rows[0].Field<string>("C_Name").ToString() 
+ " </td><td> Pax= " 
+ myds.Tables[1].Rows[0].Field<int>("pax").ToString() 
+ "</td> </tr><tr><td>Della Adventure,Kunegao,Lonavala</td><td>CheckIn Date= " 
+ myds.Tables[0].Rows[0].Field<string>("Checkin_date").ToString() 
+ "</td></tr></table>";

This is my code and I want to add image in the message body.

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
tani
  • 5
  • 4

3 Answers3

2

It seems your creating the inline HTML for message body. In this case you can generate the base64 string for image and then embed the image source for image tag with base64 string like below -

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..."/>
Bhalchandra K
  • 2,631
  • 3
  • 31
  • 43
0

Use image tag to display the image in your body of the mail.

Instead of storing the image in to DB refer the image path. Do the following steps

  1. Just upload the image in to you're server location.
  2. Store the image path in to DB
  3. Get the image path from DB and bind it to image source.

For Example.

 <img height="" width="" border="0" alt="" src="https://www.xyz.com/images/123.jpg"></img>


Bindling the image URL

<tr><td> <img height="" width="" border="0" alt=" src="+ myds.Tables[1].Rows[0].Field<string>("imageurl").ToString() + "></img></td> </tr>

Your entire code could be..

message.Body = "Dear " + myds.Tables[0].Rows[0].Field<string>("C_Name").ToString() + " <br /> <br /> Your Registrtion is Successfull...<br/><br/><table  border='4'><tr><td>Name = " + myds.Tables[0].Rows[0].Field<string>("C_Name").ToString() + " </td><td> Pax= " + myds.Tables[1].Rows[0].Field<int>("pax").ToString() + "</td> </tr>
**<tr><td> <img height="" width="" border="0" alt=" src="+ myds.Tables[1].Rows[0].Field<string>("imageurl").ToString() + "></img></td> </tr>**
<tr><td>Della Adventure,Kunegao,Lonavala</td><td>CheckIn Date= " + myds.Tables[0].Rows[0].Field<string>("Checkin_date").ToString() + "</td></tr></table>";
Bala
  • 618
  • 5
  • 21