so I know this is a widely discussed subject, nonetheless amongst all the threads i've read i haven't found a solution yet, hence the new topic
so basically i have a c# winform app to create reports on my team's activity of course i'd like to send these reports by mail
the thing is all the threads i've read/tried out discuss embedding an image FROM AN EXTERNAL FILE (bmp, gif, jpeg)
what i've been trying to do is to embed an image from a runtime graphic chart component
for example what i can do is capture the chart to a bmp and stream it to windows clipboard then paste into a mail body
of course the objective is to have this automatically, but i can't find anywhere how to include my runtime chart in a mail body.
the major issue i have encountered is everytime i try to add a stream to a linked ressource item i get that frustrating GDI++ error
here is my latest test :
string htmlBody = "<html><body><p>report</p>";
AlternateView view = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Image.Jpeg);
foreach (ChartModuleModel item in _checkedListBox.CheckedItems)
{
string itemStr = item.ToString();
MemoryStream ms = new MemoryStream();
item.Chart().SaveImage(ms, ChartImageFormat.Jpeg);
LinkedResource res =
new LinkedResource(ms, MediaTypeNames.Image.Jpeg);
res.ContentId = itemStr;
view.LinkedResources.Add(res);
htmlBody += "<p>chart : " + itemStr + "</p>";
htmlBody += "<img src=\"cid:" + itemStr + "\">";
}
htmlBody += "</body></html>";
MailMessage mail = new MailMessage();
mail.AlternateViews.Add(view);
mail.From = new MailAddress(_mailToTextBox.Text);
mail.To.Add(new MailAddress(_mailToTextBox.Text));
mail.Subject = _mailSubjectTextBox.Text;
SmtpClient client = new SmtpClient();
client.Port = 25;
client.Host = "smtp-goss.int.world.socgen";
client.Send(mail);
Thanks to you all for your help,
crazy