SMTP Mail Gönderim Sistemi
Kaynak Kodu :
// C# Programming Language
// zafercavdar
//yazılımıda email adresi ve şifre yazan yere gerekli bilgileri girmeniz gerekmektedir.
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.Mail;
using System.Diagnostics;
namespace MailSender
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox4.Enabled = false;
textBox4.Text = "Write directory of your file here.";
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mesaj = new MailMessage();//mail nesnesi
mesaj.From = new MailAddress(textBox1.Text, textBox1.Text , System.Text.Encoding.UTF8);
SmtpClient smtp = new SmtpClient();
mesaj.To.Add(textBox2.Text);
mesaj.Subject = textBox3.Text;
mesaj.IsBodyHtml = false;
mesaj.BodyEncoding = System.Text.Encoding.UTF8;
if (checkBox1.Checked)
mesaj.Attachments.Add(new Attachment(@textBox4.Text));
mesaj.Body = richTextBox1.Text;
mesaj.Priority = MailPriority.High;
smtp.Credentials = new System.Net.NetworkCredential("email adresi" , "şifre");//
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Send(mesaj);
MessageBox.Show("E-mail has been sent successfully.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
}
private void gmailToolStripMenuItem1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.gmail.com");
}
private void hotmailToolStripMenuItem1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.outlook.com");
}
private void yahooMailToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://login.yahoo.com/config/mail?&.src=ym&.intl=tr");
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox4.Enabled = true;
textBox4.Text = "";
}
else
{
textBox4.Enabled = false;
textBox4.Text = "Write your directory of file here.";
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
}
}
// zafercavdar
//yazılımıda email adresi ve şifre yazan yere gerekli bilgileri girmeniz gerekmektedir.
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.Mail;
using System.Diagnostics;
namespace MailSender
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox4.Enabled = false;
textBox4.Text = "Write directory of your file here.";
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mesaj = new MailMessage();//mail nesnesi
mesaj.From = new MailAddress(textBox1.Text, textBox1.Text , System.Text.Encoding.UTF8);
SmtpClient smtp = new SmtpClient();
mesaj.To.Add(textBox2.Text);
mesaj.Subject = textBox3.Text;
mesaj.IsBodyHtml = false;
mesaj.BodyEncoding = System.Text.Encoding.UTF8;
if (checkBox1.Checked)
mesaj.Attachments.Add(new Attachment(@textBox4.Text));
mesaj.Body = richTextBox1.Text;
mesaj.Priority = MailPriority.High;
smtp.Credentials = new System.Net.NetworkCredential("email adresi" , "şifre");//
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Send(mesaj);
MessageBox.Show("E-mail has been sent successfully.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
}
private void gmailToolStripMenuItem1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.gmail.com");
}
private void hotmailToolStripMenuItem1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.outlook.com");
}
private void yahooMailToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://login.yahoo.com/config/mail?&.src=ym&.intl=tr");
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox4.Enabled = true;
textBox4.Text = "";
}
else
{
textBox4.Enabled = false;
textBox4.Text = "Write your directory of file here.";
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
}
}