CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_web_developer_2005_express Tags:
Item Type: NewsGroup Date Entered: 5/23/2007 6:53:36 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 71 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
RichCfl
Asp.Net User
contact us form5/23/2007 6:53:36 PM

0/0

 Can anyone help, please.

I had no luck getting an answer I could understand over at the Web Forms board so I thought I'd ask here.

It's just a standard simple 'contact us' form I built in VWD Express (VB). I can't figure out how to send my form textbox values in an email, and display a 'thank you' form.

I have seen lots of confusing code with no explanations. I'm new and need the details like exactly where such code goes.

Thank you.

bullpit
Asp.Net User
Re: contact us form5/23/2007 7:11:21 PM

0/0

 

Protected  Sub Send_Email() 
            Dim msgMail As MailMessage =  New MailMessage() 
            msgMail.To = "..." 'To email address
            msgMail.From = "..." 'From email address
            msgMail.Subject = "Test Email"
            msgMail.BodyFormat = MailFormat.Text
            Dim strBody As String =  BuildMessage() 
            msgMail.Body = strBody
 
        Try
            SmtpMail.SmtpServer = "mail.something.something" 'Your Mail server
            SmtpMail.Send(msgMail)
        Catch ex As System.Exception
 
        Finally
            Response.Redirect("Thanks.aspx") 'Thank you page
        End Try
End Sub
 
'this is to build a simple text email
Public Function BuildMessage() As String
        String strBody = "Date & Time of Request:                 " + txtDateTime.Text + "\n" +
                         "Organization Name:                      " + txtOrgName.Value + "\n" +
                         "Building / Location:                    " + txtLocName.Value + "\n" +
                         "Email Address:                          " + txtEmail.Value + "\n" +
                         "Person Reporting Problem:               " + txtPersonName.Value + "\n" +
                         "Telephone:                              " + txtTel.Value + "\n" +
                         "Equipment Type:                         " + txtEquType.Value + "\n" +
                         "Make/Model Number:                      " + txtMakeNum.Value
 
        Return strBody.ToString()
End Function
Do you have access to an email server that you can use in your application?
You will need System.Web.Mail namespace.

[bullpit^-^]
RichCfl
Asp.Net User
Re: contact us form5/23/2007 9:25:04 PM

0/0

This is so frustrating I'm exhausted. 

Well, I have several email accounts if that's what you mean. I found this code to allegedly use the default.

'Specify to use the default Smtp Server

SmtpMail.SmtpServer = ""

 

'Now, to send the message, use the Send method of the SmtpMail class

SmtpMail.Send(objMM)

 

There's got to be something important I'm missing.

Where specifically does this line go?     <% @Import Namespace="System.Net.Mail" %>

Why does the tutorial use   Imports System.Net>Mail   instead?

 Why am I getting errors like:  Property 'To' is 'ReadOnly'?   'String' cannot be converted to 'System.Net.Mail.MailAddress'?    'BodyFormat' is not a member of 'System.Net.Mail.MailMessage'?     'SmtpMail' is not declared?

Thank you for your help.

manny
Asp.Net User
Re: contact us form5/23/2007 9:36:16 PM

0/0

can you post your code?
my blog on asp.net and stuff
RichCfl
Asp.Net User
Re: contact us form5/23/2007 10:09:54 PM

0/0

None of this is my code. I've tried several versions I've found. I just can't make it work.

Where does this go? <% @Import Namespace="System.Web.Mail" %>

Or is it this? Imports System.Net.Mail

This code was from a guy yesterday on the Web Forms board.

http://forums.asp.net/t/971802.aspx

Calling the function from code

MailHelper.SendMailMessage("[email protected]", "[email protected]", "[email protected]",

"[email protected]", "Sample Subject", "Sample body of text for mail message")

MailHelper.vb

Imports System.Net.Mail
Public Class MailHelper
   ''' <summary>
   ''' Sends an mail message
   ''' </summary>
   ''' <param name="from">Sender address</param>
   ''' <param name="recepient">Recepient address</param>
   ''' <param name="bcc">Bcc recepient</param>
   ''' <param name="cc">Cc recepient</param>
   ''' <param name="subject">Subject of mail message</param>
   ''' <param name="body">Body of mail message</param>
   Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As

String, ByVal subject As String, ByVal body As String)
      ' Instantiate a new instance of MailMessage
      Dim mMailMessage As New MailMessage()
      ' Set the sender address of the mail message
      mMailMessage.From = New MailAddress(from)
      ' Set the recepient address of the mail message
      mMailMessage.To.Add(New MailAddress(recepient))

      ' Check if the bcc value is nothing or an empty string
      If Not bcc Is Nothing And bcc <> String.Empty Then
         ' Set the Bcc address of the mail message
         mMailMessage.Bcc.Add(New MailAddress(bcc))
      End If

      ' Check if the cc value is nothing or an empty value
      If Not cc Is Nothing And cc <> String.Empty Then
         ' Set the CC address of the mail message
         mMailMessage.CC.Add(New MailAddress(cc))
      End If

      ' Set the subject of the mail message
      mMailMessage.Subject = subject
      ' Set the body of the mail message
      mMailMessage.Body = body

      ' Set the format of the mail message body as HTML
      mMailMessage.IsBodyHtml = True
      ' Set the priority of the mail message to normal
      mMailMessage.Priority = MailPriority.Normal

      ' Instantiate a new instance of SmtpClient
      Dim mSmtpClient As New SmtpClient()
      ' Send the mail message
      mSmtpClient.Send(mMailMessage)
   End Sub
End Class

Web.config

<?

xml version="1.0"?>
<configuration>
   <system.net>
      <mailSettings>
         <smtp from="[email protected]">
            <network host="smtp.yourdomain.com" port="25" userName="yourUserName" password="yourPassword"/>
         </smtp>
      </mailSettings>
   </system.net>
</configuration>

 

...and this one is from 4GuysFromRolla.com

Source Code for Creating an ASP.NET Visitor Feedback Page
<% @Import Namespace="System.Web.Mail" %>
<script language="vb" runat="server">

Sub btnSendFeedback_Click(sender as Object, e as EventArgs)

  'Create an instance of the MailMessage class
  Dim objMM as New MailMessage()

  'Set the properties - send the email to the person who filled out the
  'feedback form.
  objMM.To = "[email protected]"
  objMM.From = txtEmail.Text

  'If you want to CC this email to someone else, uncomment the line below
  'objMM.Cc = "[email protected]"

  'If you want to BCC this email to someone else, uncomment the line below
  'objMM.Bcc = "[email protected]"

  'Send the email in text format
  objMM.BodyFormat = MailFormat.Text
  '(to send HTML format, change MailFormat.Text to MailFormat.Html)

  'Set the priority - options are High, Low, and Normal
  objMM.Priority = MailPriority.Normal

  'Set the subject
  objMM.Subject = "4GuysFromRolla.com - Feedback"

  'Set the body
  objMM.Body = "At " + DateTime.Now + " feedback was sent from an ASP.NET " & _
               "Web page.  Below you will find the feedback message " & _
               "send by " & txtName.Text & "." & vbCrLf & vbCrLf & _
               "---------------------------------------" & vbCrLf & vbCrLf & _
               txtMessage.Text & vbCrLf


  'Specify to use the default Smtp Server
  SmtpMail.SmtpServer = ""
 
  'Now, to send the message, use the Send method of the SmtpMail class
  SmtpMail.Send(objMM)


  panelSendEmail.Visible = false
  panelMailSent.Visible = true
End Sub

</script>

<html>
<body>
  <asp:panel id="panelSendEmail" runat="server">
    <form runat="server">
      <h2>We are interested in your feedback!  Please enter the following
      requested information below to send us your comments.</h2>

      <b>Your Name:</b>
      <asp:textbox id="txtName" runat="server" />
      <br>

      <b>Your Email Address:</b>
      <asp:textbox id="txtEmail" runat="server" />
      <p>

      <b>Your Message:</b><br>
      <asp:textbox id="txtMessage" TextMode="MultiLine"
                      Columns="40" Rows="10" runat="server" />
      <p>

      <asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
                  OnClick="btnSendFeedback_Click" />
    </form>
  </asp:panel>


  <asp:panel id="panelMailSent" runat="server" Visible="False">
    An email has been sent to the email address you specified.  Thanks!
  </asp:panel>
</body>
</html>

manny
Asp.Net User
Re: contact us form5/24/2007 1:33:40 AM

0/0

ok the confusion, on your part might be caused by this::

Where does this go? <% @Import Namespace="System.Web.Mail" %>--------------this is only used if you are not using the code behind page and writing the script directly into your aspx page

Or is it this? Imports System.Net.Mail ---------------------------this is used if you are using a class file and or code behind page.

 

you will need to decide which method you wish to use...both will work, you just need to figure out your preference.

you will also have to ensure that when you test the application that you are using the correct smtpserver, if you are testing from lets say your home and are trying to test this application through your

web host smtpserver that it might fail to send because a lot of times your isp will block any smtp mail sending that is not going through there server(at least that is how it is for me, i use bellsouth.net).

 

hope that helps.

I know it can be confusing at first but once you get it working you will see it is easy.

 


 

 

 


my blog on asp.net and stuff
bullpit
Asp.Net User
Re: contact us form5/24/2007 2:13:46 AM

0/0

<% @Import Namespace="System.Web.Mail" %> goes at the top of your aspx page (after the page directive) if you are writing the server code in aspx page. The Imports System.Net.Mail goes in the aspx.vb page. If you are using aspx.cs, keyword Imports is changed to "using".

Both are namespaces that contain classes to handle your email applications and almost do the same thing, but I believe System.Web.Mail is deprecated now. Use System.Net.Mail instead.

Now coming to the email server, it is the server that handles the incoming and outgoing mails for your web application. It is not gmail, or yahoomail or any other email client. What you are refering to as servers are actually clients that work with email servers (smtp servers) at the backend. I would suggest you clear your .Net fundamentals first and then jump to building applications. It will be very hard for us to teach you A-Z of .Net here.


[bullpit^-^]
RichCfl
Asp.Net User
Re: contact us form5/24/2007 1:26:40 PM

0/0

Thank you all for your help. I'm confident you've given me the answers even though I don't understand them.

I'll study and continue trying to figure it out and if I'm successful I'll post the elementary explanation that I seek for others in my position. I'm really surprised that such a seemingly common task is so illusive with no ready-made tools for it (see BlueVoda.com). For example, I've already learned to handle my test database using the VWD tools. They should have made this tool, too.

Thank you.

Jessica Cao - M
Asp.Net User
Re: contact us form5/25/2007 1:55:38 AM

0/0

Hello RichCfl,

Here is a tutorial Vedio teching you about How Do I: Create a ?Contact Us? Page? in this site.

Hope it can give you some helps,

Jessica


Jessica Cao
Sincerely,
Microsoft Online Community Support


?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
9 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Contrastive Rhetoric: Reaching to Intercultural Rhetoric Authors: Ulla Connor, Ed Nagelhout, William V. Rozycki, Pages: 324, Published: 2008
Legal Issues for Entrepreneurs: Entrepreneurship Series Authors: Lisa Gordon-Davis, Peter Cumberlege, Pages: 252, Published: 2007
Stand Up to the IRS Authors: Frederick W. Daily, Pages: 378, Published: 2007
Microsoft FrontPage 2003: Savvy Authors: Christian Crumlish, Kate Chase, Pages: 629, Published: 2003
Mastering Dreamweaver MX Databases Authors: Susan Sales Harkins, Bryan Chamberlain, Darren McGee, Pages: 707, Published: 2003
Mastering HTML and XHTML Authors: Eric J. Ray, Pages: 1107, Published: 2002
America (the Book): A Citizen's Guide to Democracy Inaction Authors: Jon Stewart, Ben Karlin, David Javerbaum, Pages: 242, Published: 2004
Rubbers in Contact with Food Authors: J.A. Sidwell, M.J. Forrest, Rapra Technology Limited, Pages: 100, Published: 2000
Success with English Communication Authors: Viviers, Helena Van Schalkwyk, Pages: 0, Published: 1992
U.S. Immigration Made Easy Authors: Ilona Bray, Carl Falstrom, Pages: 592, Published: 2007

Web:
Contact Us Form By using the Contact Us form, your suggestion, feedback or question about library services or programs will be directed to the appropriate department. ...
Contact PHP Email Form Script w copy n paste free contact php ... Jul 9, 2008 ... Contact Form Free PHP Contact Us Form Tutorial (Current). Optimize Images For Web Page Sites ... IBDhost Contact Form (PHP Contact Us) ...
Contact Us
Contact Us Form - March of Dimes please contact your local March of Dimes ... Alabama (205) 824-0103 Alaska (907) ... To contact us by e-mail, please complete and submit the following form. ...
Contact Us form
Aveda - Contact Us Contact Us Customer Service toll free 1.800.644.4831 ... You may also contact us by phone at 866.823.1425 (North America only). We'll guide you. ...
Department of Energy - Contact Us Form Contact Us form. Use this form to provide your comments, concerns, questions, or suggestions about the Department of Energy to the Secretary. ...
About Skype: Contact us Contact us. Hi there! We really like to hear what users, journalists and all ... If that's not why you wanted to contact us, select your area of interest: ...
AirTran Airways - Contact Us contact us. send your comments to airtran airways. Due to the large volume of email we receive, we may not be able to respond to your message immediately. ...
Email Us Complete the Email Us form if your questions are not addressed in the information below. SkyMiles members log in at left to have the Customer Information ...

Videos:
Contact Us form into database tutorial Contact Us form into database tutorial
Dreamweaver CS3 tips creating a contact us form to send email ... There are many videos on You Tube with the easy things in building websites but only a couple of videos relating to PHP scripting. this video ...
STICK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ... STICK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ITALY. IDEAL TO PACK SUGAR IN STICK. SPEED UP TO 140 STICK PER MINUTE. FOR MORE ...
Magento Host - Contact us form not working! http://www.hostingcoupons.org/magento-hosting-contact-us-form-not-working/ Magento Host - Contact us form not working!
NEW S3 VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ... NEW S3 VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ITALY FOR MORE INFORMATIONS PLEASE CONTACT US: [email protected] - www ...
Html/Php Contact Form - Anti Spam Continued from: http://www.youtube.com/watch?v=qUgul1RgSGk Now that we have a contact us form, lets fight spam! Source Code: http ...
STICK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ... STICK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ITALY. IDEAL TO PACK SUGAR IN STICK. SPEED UP TO 140 STICK PER MINUTE. FOR MORE ...
Romanian Deadlift form tutorial RDL Questions? Contact us http://www.synergy-athletics.com Form video courtesy of a former D-1 strength and conditioning coach. Very good form ...
DUALPACK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM ... DUALPACK VERTICAL FORM FILL AND SEAL PACKAGING MACHINE FROM SMC ITALY. IT CAN PRINT. DOSE AND PACK SUGAR AT A SPEED OF 200 SACHETS PER MINUTE ...
Hang Clean Form / Tutorial Training Questions? Contact us, http://www.synergy-athletics.com A slightly modified version of our first hang clean video. We cut out the ...




Search This Site:










.htm pages not displaying correctly

using openquery as sql statement

problem with installing pubs database in the guided tour

login

microsoft office outlook will not start with visual c++ runtime error

connection problem

from grid layout to flow layout

my project has gone mad

.net development server

how to enable code collapse on .vb files ?

see my web page in iis

foreign key

i can't debug

query: vwd2005 error list woes

e-mail notification help!!!

send email control?

how can i change the theme of personal website starter kit?

how can i know whether a hosting support remote/network transactions?

how to refer the source of another project?

ide crashes constantly r6025 : pure virtual function call

user instances in sql (vwd)

returning to viswebdev2005 from browser

why are locations a problem?

server with windows sharepoint services 2.0?

oh why is the: current thread is not in a single-threaded apartment

help for saving files

changing the properties of a dropdownlist

a floating table?

could i shrink sql 2005 database programmatically in asp.net 2.0?

removing events from code

  Privacy | Contact Us
All Times Are GMT