How to take a screenshot and send by email programaticly on dotnet

后端 未结 2 1835
栀梦
栀梦 2021-01-03 15:19

Background:

I\'m developing a bussiness application, and in the final stages we are encountering some extrange errors, mostly with connection and so

2条回答
  •  梦毁少年i
    2021-01-03 16:12

    First of all, to send the screenshot, you can use the following code:

    //Will contain screenshot
    Bitmap screenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
    Graphics screenshotGraphics = Graphics.FromImage(bmpScreenshot);
    //Make the screenshot
    screenshotGraphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
    screenshot.save("a place to temporarily save the file", ImageFormat.Png);
    

    To send the mail through outlook, you could use the method described here

提交回复
热议问题