I'm trying to get an MS chart into an outlook email. I want to avoid saving it onto the desktop so I decided to use a MemoryStream
. This is what I've put together so far:
MemoryStream s = new MemoryStream();
chart1.SaveImage(s, ChartImageFormat.Png);
s.Position = 0;
OutlookApp outlookApp = new OutlookApp();
MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
chart1.SaveImage(s, ChartImageFormat.Png);
chart1.SaveImage(s, ChartImageFormat.Png);
mailItem.HTMLBody = "<html><body>This is the <strong>funky</strong> message body</body></html>" ;
mailItem.Attachments.Add(s);
//Set a high priority to the message
mailItem.Importance = OlImportance.olImportanceHigh;
mailItem.To = "testemail@gmail.com";
mailItem.Display(false);
//mailItem.Send();
I just can't seem to find a way to get the MemoryStream
into the email.