Asp.Net E-Posta Gönder
PostaGonder.aspx Sayfası
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <br /> Kime: <asp:TextBox ID="txbKime" runat="server"></asp:TextBox> <br /> Konu: <asp:TextBox ID="txbKonu" runat="server"></asp:TextBox> <br /> İçerik: <asp:TextBox ID="txbIcerik" runat="server" Height="100px" TextMode="MultiLine"></asp:TextBox> <br /> <asp:Button ID="btGonder" runat="server" Text="Gönder" OnClick="btGonder_Click" style="margin-left: 137px" Width="83px" /> </div> </form> </body> </html> |
PostaGonder.aspx.cs Sayfası
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; using System.Net; namespace AspNet_007_EPostaGonder { public partial class PostaGonder : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btGonder_Click(object sender, EventArgs e) { MailMessage ePosta = new MailMessage(); ePosta.From = new MailAddress("Mail Adresi"); ePosta.To.Add(txbKime.Text); ePosta.Subject = txbKonu.Text; ePosta.Body = txbIcerik.Text; SmtpClient smtp = new SmtpClient(); smtp.Credentials = new NetworkCredential("Mail Adresi", "Şifresi"); smtp.Port = 587; smtp.Host = "Mail formatı yaz"; smtp.Send(ePosta); btGonder.Text = "E-Posta Başarıyla Gönderildi"; } } } |
Leave a reply