E-Mail Application
Now create your own email application and send to any Gmail
id. For developing like this kind of application Go to Visual Studio ->
Create a New Web Site -> Add a aspx page and design like this.
- Design the page as you want and place five textboxes those are for From, Password, To, Subject and Body. Give name of these textboxes ID as txtFrom, txtPassword, txtTo, txtSubject and txtBody simultaneously.
- Go to properties of txtPassword textbox and set TextMode = Password than go to properties of txtBody textbox and set TextMode = MultiLine.
- Than place a Image Button billow all the textbox as shown in the figure above and set a image by changing its image url.
- Than place a level and go to its property and set the Text property as blank than it will show like this [Label1].
Email.aspx.cs
===========
Double click in the Image Button and write this code.
Using system.Net;
Using system.Net.Mail;
public partial class email :
System.Web.UI.Page
{
MailMessage msgobj;
protected void
ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SmtpClient serverobj = new
SmtpClient();
serverobj.Credentials = new NetworkCredential(txtFrom.Text,
txtPassword.Text);
serverobj.Port = 587;
serverobj.Host = "smtp.gmail.com";
serverobj.EnableSsl = true;
msgobj = new MailMessage();
msgobj.From = new
MailAddress("
Give Your Gmail ID like abc@gmail.com",
"
Text You Want To Show", System.Text.Encoding.UTF8);
msgobj.To.Add(txtTo.Text);
msgobj.Subject = txtSubject.Text;
msgobj.Body = txtBody.Text;
msgobj.IsBodyHtml = true;
msgobj.Priority = MailPriority.High;
msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
serverobj.Send(msgobj);
Label5.Text = "Your mail send
sucessfully...";
}
}
- For clear textboxes after sending mail write this code billow the label
foreach (Control ctrl in form1.Controls)
{
if (ctrl is TextBox)
{
TextBox tb = (TextBox)ctrl;
tb.Text = string.Empty;
}
}
Now connect the internet and run your page and see
how easily you can send email to anyone.
No comments:
Post a Comment