Results 1 to 7 of 7

Thread: send email from webform

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    send email from webform

    i have a webform with the txtboxes

    txtName
    txtFrom
    txtTo
    txtCc
    txtComments

    i have the following code.
    any help at all would be greatly appreciated
    i have a few errors so as i cannot run it the errors shall be in red below

    Public Class WebForm1

    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'Put user code to initialize the page here

    End Sub

    Public Sub sendmail()

    Dim objEmail As New MailMessage - (type mail message is not defined)

    objEmail.To = txtTo.Text

    objEmail.From = txtFrom.Text

    objEmail.Cc = txtCc.Text

    objEmail.Subject = "Test Email"

    objEmail.Body = txtName.Text & ", " & txtComments.Text

    ' objEmail.Priority = MailPriority.High

    SmtpMail.SmtpServer = "localhost" - smtpmail not declared
    Try

    SmtpMail.Send(EMail) - also not declared

    Response.Write("Your E-mail has been sent sucessfully Thank You")

    Catch exc As Exception

    Response.Write("Send failure: " + exc.ToString())

    End Try

    End Sub

    End Class

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: send email from webform

    Have you referenced the System.Web.Mail namespace?

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  3. #3

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from webform

    just done that there now buddy, searchin the web,

    now the only error it seems is that the name email is not declared
    SmtpMail.Send(EMail) - also not declared

    where should i declare this,
    thanks

  4. #4
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: send email from webform

    There is no Email object try changing it to objEmail which is the MailMessage object.

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  5. #5

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from webform

    dj that took away all my errors and now the form works i think,
    i say i think because the message appears "message sent thankyou" but no message appears in my hotmail box.

    the reason i think for this is that i am on a network coming from a router.(just started today)
    my forms are unable to be viewed over the internet from other machines
    this change has just happened today but i can test it when i get home
    this ip situation is getting corrected tommorow

    i tested a message earlier using my pickup folder and although the notepad file dissappeared nothing appeared in my hotmail.
    i hope thats why they arent reaching me.

  6. #6
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: send email from webform

    If an exception isn't thrown then the message should have been sent.

    Where is this script being executed? If it's on your local machine is an SMTP server installed? It might be worth changing localhost to the SMTP server you use for your email client.

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  7. #7

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from webform

    yeah no email is being sent,
    no errors are thrown

    i checked at home machine
    im using smpt on iis i think

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