mardi 4 août 2015

send System.Drawing.image via email

Hey Every one i want to know how send an system.drawing.image via email i am trying this code but its give me an error "a generic error GDI+"

here is my code

byte[] data = GetData(string);
                System.Drawing.Image image;
                using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(abc[i].ToString())))
                {
                    image = System.Drawing.Image.FromStream(ms);
image.Save(ms, ImageFormat.Jpeg); // error on this line
                    ms.Position = 0;

                    email.Attachments.Add(new Attachment(ms, "image/jpg"));
                }



 SmtpClient smtp = new SmtpClient(smtpServer);
            smtp.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword, smtpDomain);
            smtp.EnableSsl = enabledSsl; 
            try { smtp.Send(email); }

please help me what should do in my code

Aucun commentaire:

Enregistrer un commentaire