C#MVC发送打印屏幕图像的电子邮件附件

时间:2011-10-02 15:12:10

标签: c# model-view-controller email-attachments printscreen

这是用于打印屏幕,

using System.Drawing;
using System.Drawing.Imaging;
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

        Graphics graphics = Graphics.FromImage(printscreen as Image);

        graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);

        printscreen.Save(@"filepath", ImageFormat.Jpeg);

我尝试将它放在我的控制器中,但它不能将屏幕识别为任何东西。

这是为了附加,

System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment("you attachment file");
            mMailMessage.Attachments.Add(attachment);

我可以像这样添加文件路径吗?:new System.Net.Mail.Attachment(“filepath”);

1 个答案:

答案 0 :(得分:2)

这是一个Windows代码,可以在WinForm上运行,而不是在客户端浏览器上运行。