| 
				 C# ile GMail Hesabına Mail Gönderme 
 
			
			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.Net;
 using System.Net.Mail;
 
 namespace EMail
 {
 public partial class MailGondermeFormu : Form
 {
 public MailGondermeFormu()
 {
 InitializeComponent();
 }
 
 static bool mailSent = false;
 string[] GonderilenlerDizisi = new string[3];
 public void SendMail()
 {
 System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
 msg.To.Add(txtKime.Text);
 msg.From = new MailAddress(txtKimden.Text txtKullaniciAdi.Text System.Text.Encoding.UTF8);
 msg.Subject = txtKonu.Text;
 msg.SubjectEncoding = System.Text.Encoding.UTF8;
 msg.Body = txtMesaj.Text;
 msg.BodyEncoding = System.Text.Encoding.UTF8;
 msg.IsBodyHtml = false;
 msg.Priority = MailPriority.High;
 if (txtEkDosya.Text != "")
 {
 msg.Attachments.Add(new Attachment(txtEkDosya.Text));
 }
 
 SmtpClient client = new SmtpClient();
 client.Credentials = new System.Net.NetworkCredential(txtKullaniciAdi.Text txtSifre.Text);
 client.Port = 587;//or use 587
 client.Host = "smtp.gmail.com";
 client.EnableSsl = true;
 client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
 object userState = msg;
 try
 {
 client.SendAsync(msg userState);
 }
 catch (System.Net.Mail.SmtpException ex)
 {
 MessageBox.Show(ex.Message "Mail Gönderme Hatası");
 }
 }
 
 void client_SendCompleted(object sender AsyncCompletedEventArgs e)
 {
 MailMessage mail = (MailMessage)e.UserState;
 string subject = mail.Subject;
 
 if (e.Cancelled)
 {
 string cancelled = string.Format("[{0}] Mail gönderme iptal edildi." subject);
 MessageBox.Show(cancelled);
 }
 if (e.Error != null)
 {
 string error = String.Format("[{0}] {1}" subject e.Error.ToString());
 MessageBox.Show(error);
 }
 else
 {
 MessageBox.Show("E-Mail başarıyla gönderildi.");
 }
 mailSent = true;
 }
 
 private void btnEkle_Click(object sender EventArgs e)
 {
 openFileDialog1.ShowDialog();
 if (openFileDialog1.FileName == "")
 {
 txtEkDosya.Text = "";
 }
 txtEkDosya.Text = openFileDialog1.FileName;
 }
 
 private void btnGonder_Click(object sender EventArgs e)
 {
 this.SendMail();
 }
 
 private void btnTemizle_Click(object sender EventArgs e)
 {
 for (int i = 0; i < groupBox1.Controls.Count; i++)
 {
 if (groupBox1.Controls[i] is TextBox)
 {
 groupBox1.Controls[i].ResetText();
 }
 }
 }
 }
 }
 
				__________________ بِسْــــــــــــــــــــــمِ اﷲِارَّحْمَنِ ارَّحِيم ------------------------------------------------- Bu Soysuzlar Bu Vatansızlar Sarsada Yurdumu Ben Yaratan'dan Alırım Asil Kanı ve Gücü. -------------------------------------------------  |