Home > DeveloperSection > Forums > How to insert image in message body
Alex Leblois
Alex Leblois

Total Post:67

Points:471
Posted on    December-23-2013 3:37 AM

 C# C# 
Ratings:


 1 Reply(s)
 760  View(s)
Rate this:

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.



Pravesh Singh

Total Post:411

Points:2881
Posted on    December-23-2013 5:20 AM

Hi Alex,

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

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

Just upload the image in to you're server location.

Store the image path in to DB

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>";


Don't want to miss updates? Please click the below button!

Follow MindStick