kiran kumar

kiran kumar

  • NA
  • 1k
  • 270.9k

error in sending mail

Dec 16 2009 9:51 AM
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Text; using System.Collections.Generic; using System.Net.Mail; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { MembershipUser newuser = Membership.GetUser(CreateUserWizard1.UserName); Guid newuserid = (Guid)newuser.ProviderUserKey; SqlConnection con = new SqlConnection("Data Source=KIRAN\\SQLEXPRESS;Initial Catalog=kiran;Integrated Security=True"); con.Open(); string querystring; querystring = "insert into reg(username,password,email,securityquestion,securityanswer,userid)values(@username,@password,@email,@securityquestion,@securityanswer,@userid)"; SqlCommand cmd = new SqlCommand(querystring, con); SqlParameter uname = new SqlParameter("@UserName", SqlDbType.NVarChar, 50); uname.Value = CreateUserWizard1.UserName; cmd.Parameters.Add(uname); SqlParameter pass = new SqlParameter("@Password", SqlDbType.NVarChar, 50); pass.Value = CreateUserWizard1.Password; cmd.Parameters.Add(pass); SqlParameter ema = new SqlParameter("@Email", SqlDbType.NVarChar, 50); ema.Value = CreateUserWizard1.Email; cmd.Parameters.Add(ema); SqlParameter secques = new SqlParameter("@securityanswer", SqlDbType.NVarChar, 50); secques.Value = CreateUserWizard1.Question; cmd.Parameters.Add(secques); SqlParameter secans = new SqlParameter("@securityquestion", SqlDbType.NVarChar, 50); secans.Value = CreateUserWizard1.Answer; cmd.Parameters.Add(secans); SqlParameter uid = new SqlParameter("@userid", SqlDbType.NVarChar, 50); uid.Value = newuserid.ToString(); cmd.Parameters.Add(uid); cmd.ExecuteNonQuery(); con.Close(); kiransendmail obj = new kiransendmail(); obj.SendMail(CreateUserWizard1.UserName, CreateUserWizard1.Password, CreateUserWizard1.Email); } public class kiransendmail { System.Net.Mail.SmtpClient smtpConnection; public kiransendmail() { smtpConnection = new System.Net.Mail.SmtpClient(); smtpConnection.Host = "mail.usermail.net";//Your mail server's ip or name. smtpConnection.Port = 25;//The port smtpConnection.Credentials = new System.Net.NetworkCredential("username", "password");//Username and password to access mail server } public void SendMail(string Username, string password, string email) { string mailbody = String.Format("This is your account details. Username: {0}, Password: {1}", Username, password); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.To.Add(email); message.Subject = "Your account details"; message.From = new System.Net.Mail.MailAddress("[email protected]");//Give your from e mail address here message.Body = mailbody; smtpConnection.Send(message); } } } when i try to run this it it raises an error""Error in processing. The server response was: http://www.spamhaus.org/query/bl?ip=117.204.52.154"} System.Exception {System.Net.Mail.SmtpException} "