我通过该代码捕获屏幕截图来保存。
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] /cdn-cgi/l/email-protection", "Konu");
msg.Subject = konu;
msg.IsBodyHtml = true;
msg.Body = mesaj;
msg.BodyEncoding = System.Text.Encoding.GetEncoding(1254);
NetworkCredential guvenlikKarti = new NetworkCredential("[email protected] /cdn-cgi/l/email-protection", "*****");
client.Credentials = guvenlikKarti;
client.Port = 587;
client.Host = "smtp.live.com";
client.EnableSsl = true;
client.Send(msg);
我想这样做:如何通过 smtp 协议直接将屏幕截图作为电子邮件发送而不保存?
将位图保存到流中。然后将流附加到您的邮件消息中。例子:
System.IO.Stream stream = new System.IO.MemoryStream();
Ekran.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
stream.Position = 0;
// later:
Attachment attach = new Attachment(stream, "MyImage.jpg");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)