HOW TO INSERT IMAGE IN MESSAGE BODY

Alex Leblois

Total Post:67

Points:471
Posted by  Alex Leblois
C# 
C#
 1069  View(s)
Ratings:
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.

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How to insert image in message body

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!