Results 1 to 4 of 4

Thread: Forward Form Contents To Email

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Question Forward Form Contents To Email

    Hi, may i know how do i go about to forward information in a form to a specific email address?

  2. #2
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Re: Forward Form Contents To Email

    Like this:
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
    
            sendSomeMail()
    
        End Sub
    
        Private Sub sendSomeMail()
    
            Dim MyMail As MailMessage = New MailMessage
    
            MyMail.From = "[email protected]"
            MyMail.To = "[email protected]"
            MyMail.Subject = "Web Form Feedback"
    
            ' Grab the text in the txtq1 and txtq2 fields  
            ' from and the webform and then send it in the body
            ' of the email This is not how I would do 
            ' this in a real application but it works as an 
            ' example an should get you started.
    
            MyMail.Body = txtQ1.Text & " - " & txtQ2.Text
    
            SmtpMail.SmtpServer = "mail.somewhere.com"
            SmtpMail.Send(MyMail)
    
        End Sub
    Make sure that you do an Imports System.Web.Mail for code behind or the <% Import System.Web.Mail %> for inline at the top of your code. In that example I just put two fields on the webform. One named txtQ1 and the other named txtQ2 and then passed them to the body of am email. In a real web application you would probably want to validate the data in the controls as well as test for a successful email.

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Re: Forward Form Contents To Email

    alright, thanks alot
    ______________________________________

    Warmest Regards,

    Lex
    ______________________________________



    :|: Don't Mess With The Predator :|:

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Question Re: Forward Form Contents To Email

    how do i test to see if it's working? i'm working on a local machine...
    ______________________________________

    Warmest Regards,

    Lex
    ______________________________________



    :|: Don't Mess With The Predator :|:

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