MailMessage message_content = new MailMessage();
message_content.From = new MailAddress("Göndermek istediğiniz adres");
message_content.To.Add(textBox1.Text.Trim());
message_content.Subject = textBox2.Text.Trim();
message_content.Body = textBox3.Text.Trim();
SmtpClient smtp_client = new SmtpClient();
smtp_client.Credentials = new NetworkCredential("E-Posta", "Şifre");
smtp_client.Host = "Host adresiniz";
smtp_client.EnableSsl = true; // SSL isterseniz açık hale getirin.
smtp_client.Port = 587;
try{
smtp_client.SendAsync(message_content);
MessageBox.Show("Mesaj başarıyla gönderildi.");
}catch (SmtpException error){
MessageBox.Show(error.Message);
}
using System;
using System.Net;
using System.Net.Mail;
class Program
{
static void Main(string[] args)
{
try
{
string smtpServer = "mail.example.com"; //SMTP sunucusu adresi
int port = 587; //SMTP sunucusu port numarası
string senderEmail = "[email protected]"; //Gönderen e-posta adresi
string password = "password"; //Gönderen e-posta hesabının şifresi
string recipientEmail = "[email protected]"; //Alıcı e-posta adresi
MailMessage mail = new MailMessage();
mail.From = new MailAddress(senderEmail);
mail.To.Add(recipientEmail);
mail.Subject = "Test Email"; //E-posta konusu
mail.Body = "This is a test email."; //E-posta içeriği
SmtpClient smtpClient = new SmtpClient(smtpServer, port);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential(senderEmail, password);
smtpClient.EnableSsl = true;
smtpClient.Send(mail);
Console.WriteLine("E-posta gönderildi.");
}
catch (Exception ex)
{
Console.WriteLine("E-posta gönderirken bir hata oluştu: " + ex.Message);
}
}
}
Hocam eline sağlık çalışıyor ancak kusuruma bakmayın acemiliktendir, ilk script bunu yaptım ancak derleyince 65mb oluyor çünkü çerçeve içine eklendi diyor, ancak çerçevesiz çalıştırısam başka pc de çalışmıyor, ancak .net 8.0 yüklüyse çalışıyor. ben nerde hata yapıyorum?C#:using System; using System.Net; using System.Net.Mail; class Program { static void Main(string[] args) { try { string smtpServer = "mail.example.com"; //SMTP sunucusu adresi int port = 587; //SMTP sunucusu port numarası string senderEmail = "[email protected]"; //Gönderen e-posta adresi string password = "password"; //Gönderen e-posta hesabının şifresi string recipientEmail = "[email protected]"; //Alıcı e-posta adresi MailMessage mail = new MailMessage(); mail.From = new MailAddress(senderEmail); mail.To.Add(recipientEmail); mail.Subject = "Test Email"; //E-posta konusu mail.Body = "This is a test email."; //E-posta içeriği SmtpClient smtpClient = new SmtpClient(smtpServer, port); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(senderEmail, password); smtpClient.EnableSsl = true; smtpClient.Send(mail); Console.WriteLine("E-posta gönderildi."); } catch (Exception ex) { Console.WriteLine("E-posta gönderirken bir hata oluştu: " + ex.Message); } } }
Kodu çalıştırmadan önce, gönderen adresi, şifresi, alıcı adresi ve SMTP sunucusu bilgilerini doğru şekilde değiştirdiğinizden emin olun.
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.