我做了一个小程序捕捉使用此代码屏幕:附加图片邮寄
Bitmap b = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(Point.Empty,Point.Empty,Screen.PrimaryScreen.WorkingArea.Size);
现在我想的截图附加到邮件。我已经编写了用于发送邮件的必要代码,我只需要附加图像。这里是我用于邮件的代码:
MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.Subject = "Subject";
message.Body = "Body";
message.To.Add("[email protected]");
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("[email protected]", "password");
client.Host = "smtp.gmail.com";
client.Port = 587;
client.EnableSsl = true;
client.Send(message);
你能帮我吗?谢谢。
请看看这个问题,http://stackoverflow.com/q/2825950/1443529。你可以在构造函数中使用'Attachment'来接受'Attachment(Stream,ContentType)' – cpz
对于内联附件,你可以看看@JeremyThompson的参考文献。 – cpz