C# ile Mail Gönderme programı kodlamaya çalışıyorum fakat takıldığım bir yer var. İçeriğe dosya eklemeden mail gönderimi başarısız oluyor. Birkaç fikir denedim ama çalışmadı.
Yeni bir void mi açmalıyım yoksa void'e ekleme mi yapmalıyım anlamadım.
C#:
public class SendMail
{
public void Microsoft(string GondericiAdSoyad,string GondericiMail,string GondericiPass,string AliciMail,string Baslik ,string icerik, string Ek)
{
SmtpClient sc = new SmtpClient();
sc.Port = 587;
sc.Host = "smtp.outlook.com";
sc.EnableSsl = true;
sc.Credentials = new NetworkCredential(GondericiMail, GondericiPass);
MailMessage email = new MailMessage();
email.From = new MailAddress(GondericiMail, GondericiAdSoyad);
email.To.Add(AliciMail);
email.Subject = Baslik;
email.IsBodyHtml = true;
email.Body = icerik;
if (Ek != null)
{
email.Attachments.Add(new Attachment(Ek));
}
sc.Send(email);
C#:
if (comboBoxSunucu.Text == "Microsoft")
{
SendMail sm = new SendMail();
sm.Microsoft(txtGondericiAdSoyad.Text, txtGondericiMail.Text, txtGondericiPass.Text, txtAlici.Text, txtBaslik.Text, txticerik.Text, txtEk.Text);
MessageBox.Show("Mail Gönderildi.");
}
Son düzenleyen: Moderatör: