I want to send the image in the body of the mail. Here, I am loading a chart based on the database records. I converted the chart into bytes by the following code:
string base64 = Request.Form[hfImageData.UniqueID].Split(',')[1];
byte[] bytes = Convert.FromBase64String(base64);
Now, I want to convert this bytes array into Image and to add the image in the body of the mail.
This is my send mail code:
MailMessage message = new MailMessage();
string fromEmail = "domain.com";
string fromPW = "12345";
string toEmail = "abcde@gmail.com";
message.From = new MailAddress(fromEmail);
message.To.Add(toEmail);
message.Subject = "Chart Mail";
message.Body = "Hi Team";
message.IsBodyHtml = true;
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
SmtpClient smtpClient = new SmtpClient("domain.com", 1234);
smtpClient.EnableSsl = false;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential(fromEmail, fromPW);
smtpClient.Send(message.From.ToString(), message.To.ToString(), message.Subject, message.Body);
In the above code, I want to convert the bytes to image and need to send in the body of the mail. Please suggest.