TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
alrodean fransmab
NA
36
11k
Sending emails using asp.net
Oct 14 2013 3:29 AM
Hi im trying to send an email with my website if a user forgets a password :
Here is my code :
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Net.Mail;
namespace RecruitMe
{
public partial class PassAssist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl login2 = (HtmlGenericControl)Master.FindControl("login1");
login2.Visible = false;
HtmlGenericControl lblhead2 = (HtmlGenericControl)Master.FindControl("lbls");
lblhead2.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.DataBind();
while(GridView1.Rows.Count == 0)
{
lblError.Visible = true;
}
f1.Visible = true;
lblQ.Text = GridView1.Rows[0].Cells[3].Text;
}
protected void Button3_Click1(object sender, EventArgs e)
{
if (txtA.Text == GridView1.Rows[0].Cells[4].Text)
f2.Visible = true;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton1.Checked == true)
Button4.Text = "Send";
else
Button4.Text = "Choose method";
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton2.Checked == true)
Button4.Text = "Display";
else
Button4.Text = "Choose method";
}
protected void Button4_Click(object sender, EventArgs e)
{
if (Button4.Text == "Display")
{
Label5.Text = GridView1.Rows[0].Cells[2].Text;
Label5.Visible = true;
}
else if (Button4.Text == "Send")
{
if (TextBox2.Text == GridView1.Rows[0].Cells[0].Text)
{
Label6.Visible = false;
MailMessage mail = new MailMessage();
mail.To.Add(TextBox2.Text);
mail.From = new MailAddress("
[email protected]
");
mail.Subject = "Your Recruit me password";
mail.Body = "Hello " + GridView1.Rows[0].Cells[1].Text + "/n" + "As requested here is your Recruit Me password below" + "/n" + "Username :" + GridView1.Rows[0].Cells[1].Text + "/n" + "Password :" + GridView1.Rows[0].Cells[2].Text;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("username", "password"); // only added my username and no the whole
[email protected]
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.Send(mail);
}
else
{
Label6.Visible = true;
}
}
else
{
}
}
}
i get an error sending mail failed
Help please
Reply
Answers (
3
)
twitter integration using Oauthtokens
on controls in asp.net