using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnTemizle_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
}
private void btnGönder_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
{
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
mail.To.Add(textBox4.Text);
mail.From = new MailAddress(textBox1.Text);
mail.Subject = textBox5.Text;
mail.Body = textBox3.Text;
client.Send(mail);
MessageBox.Show("Mesaj gönderildi", "Bildirim", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else MessageBox.Show("Lütfen Boş alanları dolduralım", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
catch
{
MessageBox.Show("Gmail Adı veya şifre hatalı", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}