Here is my snippet code:
...
Bitmap bmp;
...
MemoryStream = new MemoryStream();
bmp.Save(memStream, ImageFormat.Jpeg);
...
ContentType contentType = new ContentType();
contentType.MediaType = MediaTypeNames.Image.Jpeg;
contentType.Name = "screen";
MailMessage mail = new MailMessage();
...
mail.Attachments.Add(new Attachment(memStream, contentType));
...
SmtpClient.Send(mail);
ido shahar21 pointsPosted May 25, 2009, 9:07 AM EDT
Hi, Where did you define the "memStream"you created new object of MemoryStream but without to declare "memStream"there.Bitmap bmp;
...
MemoryStream = new MemoryStream(); //Old one
MemoryStreammemStream= new MemoryStream(); //new onebmp.Save(memStream, ImageFormat.Jpeg);
...
ContentType contentType = new ContentType();
contentType.MediaType = MediaTypeNames.Image.Jpeg;
contentType.Name = "screen";
MailMessage mail = new MailMessage();
...
mail.Attachments.Add(new Attachment(memStream, contentType));
...
SmtpClient.Send(mail);
Ondrej2 pointsPosted May 25, 2009, 11:16 AM EDT
I have it like this:
MemoryStream memStream = new MemoryStream();efrey kong4 pointsPosted Jun 20, 2009, 2:36 AM EDT
MemoryStreammemStream= new MemoryStream(); //new onebmp.Save(memStream, ImageFormat.Jpeg);
...
ContentType contentType = new ContentType();
contentType.MediaType = MediaTypeNames.Image.Jpeg;
contentType.Name = "screen";
MailMessage mail = new MailMessage();
...
mail.Attachments.Add(new Attachment(memStream, contentType));
-----------------------------------------------------------------------------memStream.Position should be set to 0 afterbmp.Save(memStream, ImageFormat.Jpeg);and then , It works.I have met the same issue before.