can u help me how to send auto response emails to the user wen he register in to our account.it includes both sending of username and passwords or clicking the link den it account is activated...can u help me in this
if some one provide me some sample projects based on this concept might help full for me.
waiting for ur reponses
Loading
Abhimanyu K VatsaPosted May 19, 2011, 1:38 AM
No prob, let's discuss here too.
you want to send (mail) the registration details to user who is registering...right Gawtham.
If so, then you have to create (configure) your smtp here too, this also requires the smtp. If you have, create some functions in code-behind which inserts the user details (id, pass, etc) to database and call another function to send the mail containing his infos. Here you go...
protected void submit_Click(object sender, EventArgs e)
{
execution(); //this function will insert the record (id, pass etc in db) and send the mail too.
}
public void execution()
{
//place the sql insert methods there
sendmail(fullname, emailid, username, password);
}
public void sendmail(string fullname, string emailid, string username, string password)
{
string smsg = "New Registration:
";
smsg += "
Name: " + fullname;
smsg += "
Username: " + username;
smsg += "
Password: " + password;
smsg += "
";
smsg += "Administrator";
MailMessage message = new MailMessage();
try
{
message.To.Add(new MailAddress(emailid));
message.From = new MailAddress("[email protected]");
message.Subject = "New Registration";
message.Body = smsg;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Port = 587; // Gmail works on this port 587
client.Host = "smtp.gmail.com";
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("[email protected]", "password");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = nc;
client.Send(message);
}
catch
{
//place the catch statements here
}
}
Place any url for verification in your mail or you may send any random number in email and ask the user to verify using that number.
Hope this helps
Suthish NairPosted May 19, 2011, 6:20 AM
Gowtham manjuPosted May 19, 2011, 6:07 AM
Abhimanyu K VatsaPosted May 19, 2011, 4:20 AM
For this issue,
First, check out your smtp by contacting to hosting company's tech team. They will provide you the informations.
Second, post the sample codes that you will be using and getting errors.
Note: Sometimes smtp works on outlook but not on site mailing list, this could be an issue. This issue comes because of some authentication or say settings on mail server. Ask from Host Tech Team for this. Even you can ask for sample code from them. If they will not provide you then switch your host. Alternatively, you can use gmail or yahoo smtp, that's free.
Hope this helps.
Gowtham manjuPosted May 19, 2011, 2:39 AM
Anil KumarPosted May 19, 2011, 1:50 AM
In your older thread (link is given by Abhi) , you persist on sample code project. Though Abhi has given you a nice code for your problem.
Prasant JinagaPosted May 19, 2011, 1:25 AM
I thunk U can Use Microsoft's Enterprise Libray for this,In which there are so many trace listners available like Database trace listner or email trace listner.Foe Example if u use Database trace listner if any logging happens into the databse in that case u can use email trace listner.
Thaks,
Prasant