· 8 years ago · Jun 25, 2018, 04:24 AM
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using System.Net.Mail;
10using System.Net;
11
12namespace E_Mail_Sender
13{
14 public partial class Form1 : Form
15 {
16 public Form1()
17 {
18 InitializeComponent();
19 }
20
21 private void btnGonder_Click(object sender, EventArgs e)
22 {
23 try
24 {
25 if (!txtemail.Text.Contains("@gmail.com"))
26 {
27 MessageBox.Show("email adresiniz, @gmail.com seklinde olmalidir.");
28 return;
29 }
30 btnGonder.Enabled = false;
31 MailMessage message = new MailMessage();
32 message.From = new MailAddress(txtemail.Text);
33 message.Subject = txtkonu.Text;
34 message.Body = txtmesaj.Text;
35 foreach (string s in txtAlicilar.Text.Split(';'))
36 message.To.Add(s);
37 SmtpClient client = new SmtpClient();
38 client.Credentials = new NetworkCredential(txtemail.Text, txtsifre.Text);
39 client.Host = "smtp.gmail.com";
40 client.Port = 587;
41 client.EnableSsl = true;
42 client.Send(message);
43 }
44 catch
45 {
46 MessageBox.Show("Kullanici adi veya sifre hatali!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
47 }
48 finally
49 {
50 btnGonder.Enabled = true;
51 }
52
53 }
54
55 }
56}