C# Otomatik mail gönderme

Pesimist

Silver Üye
Katılım
1 Ağu 2021
Mesajlar
86
Beğeniler
31
Yaş
24
C#:
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;
using System.Net.Mail;

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

        private void button1_Click(object sender, EventArgs e)
        {
            SmtpClient sc = new SmtpClient();
            sc.Port = 587;
            sc.Host = "smtp.gmail.com";
            sc.EnableSsl = true;
            sc.Credentials = new NetworkCredential("mail", "şifre");
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(textBox1.Text.ToString());
            mail.To.Add(textBox2.Text.ToString());
            mail.Subject = textBox3.Text.ToString();
            mail.IsBodyHtml = true;
            mail.Body = textBox4.Text.ToString();
            sc.Send(mail);
            MessageBox.Show("Mesaj başarılı bir şekilde iletildi.", "İleti", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        }
    }
}

C# Kütüphanemize eklememiz gereken kodlar;

using ;
using .Mail;​
 
C#:
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;
using System.Net.Mail;

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

        private void button1_Click(object sender, EventArgs e)
        {
            SmtpClient sc = new SmtpClient();
            sc.Port = 587;
            sc.Host = "smtp.gmail.com";
            sc.EnableSsl = true;
            sc.Credentials = new NetworkCredential("mail", "şifre");
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(textBox1.Text.ToString());
            mail.To.Add(textBox2.Text.ToString());
            mail.Subject = textBox3.Text.ToString();
            mail.IsBodyHtml = true;
            mail.Body = textBox4.Text.ToString();
            sc.Send(mail);
            MessageBox.Show("Mesaj başarılı bir şekilde iletildi.", "İleti", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        }
    }
}

C# Kütüphanemize eklememiz gereken kodlar;

using ;
using .Mail;​

VB kullanan arkadaşlar için vb hali.
Kod:
Dim mail As New MailMessage()


mail.From = New MailAddress("xx@xx")
mail.[To].Add("xx@xx")


mail.Subject = "This is an email"
mail.Body = "this is a sample body"

Dim smtp As New SmtpClient("localhost")


Try
    smtp.Send(mail)
    Response.Write("Your Email has been sent sucessfully - Thank You")
Catch exc As Exception
    Response.Write("Send failure: " & exc.ToString())
End Try
 
eline sağlık brom bunu arıyordum gayet başarılı
 
C#:
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;
using System.Net.Mail;

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

        private void button1_Click(object sender, EventArgs e)
        {
            SmtpClient sc = new SmtpClient();
            sc.Port = 587;
            sc.Host = "smtp.gmail.com";
            sc.EnableSsl = true;
            sc.Credentials = new NetworkCredential("mail", "şifre");
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(textBox1.Text.ToString());
            mail.To.Add(textBox2.Text.ToString());
            mail.Subject = textBox3.Text.ToString();
            mail.IsBodyHtml = true;
            mail.Body = textBox4.Text.ToString();
            sc.Send(mail);
            MessageBox.Show("Mesaj başarılı bir şekilde iletildi.", "İleti", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        }
    }
}

C# Kütüphanemize eklememiz gereken kodlar;

using ;
using .Mail;​
hemen denemeye vınnnnnnnn
 

  Şuanda konuyu görüntüleyen kullanıcılar


Üst Alt