using System.Net.Mail;
using System.Net;
private void btn_dosyaekle_Click(object sender, EventArgs e)
{
OpenFileDialog dosya = new OpenFileDialog();
dosya.Title = "www.halilyanik.com";
dosya.ShowDialog();
DosyaYolu = dosya.FileName;
label3.Text = "Dosya Eklendi";
}
private void btn_mailgonder_Click(object sender, EventArgs e)
{
SmtpClient sc = new SmtpClient();
sc.Port = 587;
sc.Host = "smtp.gmail.com";
sc.EnableSsl = true;
string kime = textBox1.Text;
string konu = textBox2.Text;
string icerik = textBox3.Text;
sc.Credentials = new NetworkCredential("mailadresiniz@gmail.com", "şifreniz");
MailMessage mail = new MailMessage();
mail.From = new MailAddress("posta@gmail.com", "Ahmet Cansever");
mail.To.Add(kime);
//mail.To.Add("alici2@mail.com");
mail.Subject = konu;
mail.IsBodyHtml = true;
mail.Body = icerik;
mail.Attachments.Add(new Attachment(DosyaYolu));
sc.Send(mail);