Click here to Skip to main content
15,921,643 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am Designing and Developing a WebSite for a B&B so i want to use the B&B email as a database, when ever someone one Click Book a room we will receive a notification from our email with all his details...and i believe this would be much more safe
Posted

C#
private void send_mail()
{
     System.Net.Mail.MailMessage Email = new System.Net.Mail.MailMessage();
     Email.From = new System.Net.Mail.MailAddress("mail@id.com");
     Email.To.Add(EmailTextBox.Text);
     Email.Subject = Subject.Text;
     Email.Body = Subject0.Text;

     System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
    mailClient.Credentials = new System.Net.NetworkCredential("domain@hotel.com", "s#a(p*)");
            mailClient.Host = "192.167.21.12";
            mailClient.Port = 25;
            mailClient.Send(Email);
        }


        protected void SendMailButton_Click(object sender, EventArgs e)
        {
            send_mail();

        }
 
Share this answer
 
No.
You have it completely the wrong way round: an email system is not, and never will be a database. Delivery times for emails is not guaranteed in any way, shape or form: they may not even arrive!

By all means send yourself an email when you book a room via a database (though there are probably better ways to handle this) but don't try to turn it round - you will come unstuck remarkably quickly!
 
Share this answer
 
Comments
Xolanii 10-Aug-13 5:37am    
I was just trying my luck. So can a Database sand an Email automatically when anything is triggered? Like the Submit Booking Button?
OriginalGriff 10-Aug-13 5:56am    
Yes - but there are probably still better ways to do this, email notification is probably unnecssary which means people will ignore ithem, and maybe important ones as well.
But...
http://claysql.blogspot.co.uk/2009/02/send-database-mail-from-trigger.htm
Adarsh chauhan 14-Aug-13 6:11am    
well said Mr. Griff.. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900