hi dears;
I have a image that stored in database , I want to retrieve and send to image as embedded in body .
var con = new SqlConnection(@"Data Source=DBSRV;Initial Catalog=DBNAME;user=DBUSER;pwd=DBPWD");
con.Open();
var stream = new MemoryStream();
var cmd = new SqlCommand("SELECT IMAGE FROM TABLE",con);
var image = (byte[])cmd.ExecuteScalar();
stream.Write(image, 0, image.Length);
con.Close();
var bitmap = new Bitmap(stream);
var memStream = new MemoryStream();
bitmap.Save(memStream, ImageFormat.Jpeg);
var contentType = new ContentType {MediaType = MediaTypeNames.Image.Jpeg, Name = "screen"};
var mail = new MailMessage();
var smtpServer = new SmtpClient("",587);
mail.From = new MailAddress("", "");
mail.To.Add("");
mail.IsBodyHtml = true;
var oAttachment = new Attachment(memStream, contentType);//oAttachment = new Attachment(GP.Firmalogo);mail.Attachments.Add(oAttachment);
const string contentId = "companylogo";
oAttachment.ContentId = contentId;
mail.Body = "<table style='border:6px solid black ;'width='100%'><img src='cid:" + contentId +"'><b></b></font>";
smtpServer.Credentials = new NetworkCredential("", "");
smtpServer.Send(mail);
mail.Dispose();