通过C#发送截图
我通过该代码捕获屏幕截图来保存。
Graphics Grf;
Bitmap Ekran = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppPArgb);
Grf = Graphics.FromImage(Ekran);
Grf.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
Ekran.Save("screen.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
然后将保存的屏幕截图作为电子邮件发送:
SmtpClient client = new SmtpClient();
MailMessage msg = new MailMessage();
msg.To.Add(kime);
if (dosya != null)
{
Attachment eklenecekdosya = new Attachment(dosya);
msg.Attachments.Add(eklenecekdosya);
}
msg.From = new MailAddress("[email protected]", "Konu");
msg.Subject = konu;
msg.IsBodyHtml = true;
msg.Body = mesaj;
msg.BodyEncoding = System.Text.Encoding.GetEncoding(1254);
NetworkCredential guvenlikKarti = new NetworkCredential("[email protected]", "*****");
client.Credentials = guvenlikKarti;
client.Port = 587;
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Send(msg);
我想这样做:如何通过 smtp 协议直接将屏幕截图作为电子邮件发送而不保存?
I'm saving by capturing screenshot via that code.
Graphics Grf;
Bitmap Ekran = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppPArgb);
Grf = Graphics.FromImage(Ekran);
Grf.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
Ekran.Save("screen.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Then send this saved screenshot as e-mail:
SmtpClient client = new SmtpClient();
MailMessage msg = new MailMessage();
msg.To.Add(kime);
if (dosya != null)
{
Attachment eklenecekdosya = new Attachment(dosya);
msg.Attachments.Add(eklenecekdosya);
}
msg.From = new MailAddress("[email protected]", "Konu");
msg.Subject = konu;
msg.IsBodyHtml = true;
msg.Body = mesaj;
msg.BodyEncoding = System.Text.Encoding.GetEncoding(1254);
NetworkCredential guvenlikKarti = new NetworkCredential("[email protected]", "*****");
client.Credentials = guvenlikKarti;
client.Port = 587;
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Send(msg);
I want to do this : How can I send a screenshot directly as e-mail via smtp protocol without saving?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将位图保存到流中。然后将流附加到您的邮件消息中。例子:
Save the Bitmap to a Stream. Then attach the Stream to your mail message. Example:
使用这个:
Use this: