我做了一個小程序捕捉使用此代碼屏幕:附加圖片郵寄
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