HI all
i MADE A REGISTRATION FORM VIA asp.nET AND i SAVE MY DATA INTO A DATABASE IN SQL SERVER
i NEED TO SEND AN EMAIL TO ADMINISTRATOR EACH TIME A NEW RECORD INSERTED TO THE DATABASE
THANKS
Printable View
HI all
i MADE A REGISTRATION FORM VIA asp.nET AND i SAVE MY DATA INTO A DATABASE IN SQL SERVER
i NEED TO SEND AN EMAIL TO ADMINISTRATOR EACH TIME A NEW RECORD INSERTED TO THE DATABASE
THANKS
heres an example in C#
MattCode:private void SomeFunction()
{
// Insert Record into DataBase
// Generate the body of the email
string sBody = "A new record has been inserted";
// Send the Email
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
msg.BodyFormat = System.Web.Mail.MailFormat.Html;
msg.From = sFromEmail;
msg.To = sToEmail;
msg.Subject = sSubject;
msg.Body = sBody;
System.Web.Mail.SmtpMail.Send(msg);
}
Best way to do it is setup a TRIGGER in the database.
You can setup an AFTER OF INSERT trigger to send an email to the administrator each time a record is sucessfully inserted in the database.
Using triggers email will be generated any time a record is inserted, regardless of how was inserted.
I hope this helps.
Sidney Orret
would you please tell me how can I do that
when I try this it sends to all the mail inside the domain but it does not send to any mail such as yahoo or hotmail