CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2002
    Location
    egypt
    Posts
    13

    Post sending mail from ASP.net

    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

  2. #2
    Join Date
    Oct 1999
    Location
    Colorado
    Posts
    288
    heres an example in C#

    Code:
    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

  3. #3
    Join Date
    Oct 2002
    Posts
    1

    Exclamation

    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

  4. #4
    Join Date
    Sep 2002
    Location
    egypt
    Posts
    13
    would you please tell me how can I do that

  5. #5
    Join Date
    Sep 2002
    Location
    egypt
    Posts
    13
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured