C# MVC 发送打印屏幕图像的电子邮件附件
这是用于打印屏幕的,
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");
This is for printing screen,
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);
I tried putting this in my controller but it does not recognize Screen as anything.
This is for attaching,
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("you attachment file");
mMailMessage.Attachments.Add(attachment);
Can I just add the filepath like this?: new System.Net.Mail.Attachment("filepath");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是 Windows 代码,可以在 WinForm 上运行,而不是在客户端浏览器上运行。
It's a Windows code and can run on WinForm not on client browser.