Send email with a resized picture with asp.net

64 Views Asked by At

It seems I need to get "g" into the attachment in place of fileUpload1.PostedFile. I just can't seem to figure it out. Any help is appreciated. I tried to use g.save(@"c:\Temp\test.jpg"), but it won't save either :(

var  bmp = new Bitmap(FileUpload1.PostedFile.InputStream);
                 var newImage = new Bitmap(200,200);
                 var g = Graphics.FromImage(newImage);
                  g.DrawImage(bmp, 0, 0, 200, 200);

                string fileName = 
Path.GetFileName(FileUpload1.PostedFile.FileName);
                Attachment myAttachment = new 
Attachment(FileUpload1.FileContent, fileName);
                mail.Attachments.Add(myAttachment);
0

There are 0 best solutions below