C# E-mail Gönderme

  • Konbuyu başlatan Konbuyu başlatan Method
  • Başlangıç tarihi Başlangıç tarihi
20
EXE RANK

Method

Fexe Kullanıcısı
Puanları 0
Çözümler 0
Katılım
5 May 2010
Mesajlar
30,484
Tepkime puanı
0
Puanları
0
Yaş
34
Method
Kod:
[FONT=Verdana][SIZE=2]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;

namespace mailgonder
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private bool SendMail(string to, string subject, string message, string name)
        {
            try
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();


                System.Net.NetworkCredential cred = new  System.Net.NetworkCredential(cmbKullaniciAdi.Text.Trim(),  txtSifre.Text.Trim());
                mail.To.Add(to);
                mail.Subject = subject;


                mail.From = new System.Net.Mail.MailAddress(cmbKime.Text, name);
                mail.IsBodyHtml = true;
                mail.Body = message;
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
                smtp.UseDefaultCredentials = false;
                smtp.EnableSsl = true;
                smtp.Credentials = cred;
                smtp.Send(mail);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SendMail(cmbKime.Text, txtKonu.Text, txtMesaj.Text, cmbKimden.Text);
            
        }

       
    }
}    [/SIZE][/FONT]
 
Geri
Üst