I have looked on the net, and have gone through alot of examples but I still do not understand how this works and how I can refer to an existing html code.
I found this the following code online that may look useful to you but not me. In my code i have this:
sb.Append("I put any HTML code here and images etc. I would like to place the image here);
that is where I would like to insert the image.
// send mail to the new user who has registered.
protected void yourButton_Click(object sender, EventArgs e)
string strMailContent = "Welcome new user";
string fromAddress = "firstname.lastname@example.org";
string toAddress = "email@example.com";
string contentId = "image1";
string path = Server.MapPath(@"images/Logo.jpg"); // my logo is placed in images folder
MailMessage mailMessage = new MailMessage( fromAddress, toAddress );
mailMessage.Bcc.Add("firstname.lastname@example.org"); // put your id here
mailMessage.Subject = "Welcome new User";
LinkedResource logo = new LinkedResource(path);
logo.ContentId = "companylogo";
// done HTML formatting in the next line to display my logo
AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/><br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);
mailMessage.IsBodyHtml = true;
SmtpClient mailSender = new SmtpClient("localhost"); //use this if you are in the development server