使用asp.net发送带有调整大小图片的电子邮件

时间:2018-05-21 18:06:56

标签: c# asp.net jpeg bmp aspx-user-control

似乎我需要得到" g"在附件中代替fileUpload1.PostedFile。我似乎无法弄明白。任何帮助表示赞赏。我尝试使用g.save(@" c:\ Temp \ test.jpg"),但它不会保存:(

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 个答案:

没有答案