Click to See Complete Forum and Search --> : sending mail from ASP.net


zeza
September 30th, 2002, 10:01 AM
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

MRutledge
September 30th, 2002, 07:15 PM
heres an example in C#


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);
}


Matt

sorret
October 19th, 2002, 05:30 PM
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

zeza
October 20th, 2002, 09:38 AM
would you please tell me how can I do that

zeza
November 3rd, 2002, 09:49 AM
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