Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 16th, 2007, 12:22 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cannot receive other info from user submitted feed

Hi all,

I'm new to this thing so pls bear with me...I'm using Visual Web Developer 2005 Express to develop a real estate website. I have a feedback form at contact.aspx. It contains the following items: Name, email, phone#, subject (a drop-down list), and a comments box.


1) I'm only receiving the user's email address and the comments. I would also like to receive their name, phone#, and whatever subject they've selected. How do I do this? Here's my VB code:


Imports System.Net.Mail.SmtpClient

Partial Class contact2
    Inherits System.Web.UI.Page




    Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
        SendMail(txtEmail.Text, txtComments.Text)
    End Sub
    Private Sub SendMail(ByVal from As String, ByVal body As String)

        Dim mailServerName As String = "smtp.MyDomain.com"
        Dim message As MailMessage = New MailMessage(from, "Me@MyDomain.com", "feedback", body)
        Dim mailClient As SmtpClient = New SmtpClient

        mailClient.Host = mailServerName
        mailClient.Send(message)
        message.Dispose()



    End Sub

End Class



Can someone pls help me with this?


2) I would also like to include a confirmation message showing the message has been sent but I don't know how to do it.

Thanks in advance.

AJ

I'm a newbie...so please bear with me...
Reply With Quote
  #2 (permalink)  
Old October 16th, 2007, 12:43 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If i had to guess I would say your variable named body is an empty string which would be why you are not getting any data back. This would imply, of course, that the text area txtComments does not have any data in it.

In so far as number 2 is concerened, you can accomplish by writing values out to a Literal or Label control saying that the email has been sent.

hth.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
Reply With Quote
  #3 (permalink)  
Old October 16th, 2007, 01:41 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Are you asking how to extend this code? Wouldn't that be a matter of adding extra parameters to the SendMail method and pass them to it? E.g.

SendMail(txtEmail.Text, txtComments.Text, txtPhoneNumber.Text)

Private Sub SendMail(ByVal from As String, ByVal body As String, ByVal phoneNumber As String)

  Dim mailServerName As String = "smtp.MyDomain.com"
  Dim message As MailMessage = New MailMessage(from, "Me@MyDomain.com", "feedback", body & phoneNumber)
  Dim mailClient As SmtpClient = New SmtpClient

  mailClient.Host = mailServerName
  mailClient.Send(message)
  message.Dispose()
End Sub

In this example, I just concatenate the phone number to the body. However, you can do it in a more structured way:

Dim mailBody As String
mailBody = body & vbCrLf & "Phonenumber: " & mailBody
.... New MailMessage(from, "Me@MyDomain.com", "feedback", mailBody)

This code creates a new variable mailBody, and then assigns the body, together with the static text Phonenumber: and the actual value to it.

Instead of calling this code in SendMail you can also do it in the actual page, and then pass mailBody to the SendMail method.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: When You Were Young by The Killers (Track 3 from the album: Sam's Town) What's This?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grabbing user login info Quick209 ASP.NET 2.0 Basics 1 May 12th, 2006 07:06 PM
Examples of storing user info from db in profiles? bpdsmark ASP.NET 2.0 Basics 0 March 11th, 2006 03:13 PM
why doesn't my new database carry old user info? Cinderella SQL Server 2000 1 June 21st, 2005 01:36 PM
HttpContext.Current.Cache used to store user info? flyin General .NET 11 April 6th, 2004 03:57 PM
How do I store user login info to use in a form? lanctotd Classic ASP Basics 1 July 15th, 2003 08:06 PM



All times are GMT -4. The time now is 09:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.