473,756 Members | 3,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Miscellaneous ASP.NET question on a mail form...

My ISP provides this sample for an ASP.NET capable email form.

If you have any idea about how to do the following, I would greatly
appreciate your help.

I have a few alterations that I would like to implement, but I am not sure
where to begin.

First:

I want to implement the code in a codebehind page instead of in the
mailform.aspx page. I am not sure where I would put the code. I also know
that there are differences in background operations between ASP.NET 1.1 and
ASP.NET 2.0, but I don't know if the code would differ much. In other stuff
I found on the internet, the SMTP server was identified in a <mailsettings >
section in the web.config file. That seems cleaner to me, but I don't know
how the code would change. I probably would skip the code identifying the
server.

Second:

I already have an old mail form that was implemented using a CGI. I also
used a javascript based CAPTCHA function in that form to cut down on
automated spam.
In that instance the old form tag included and action attribute that pointed
to the cgi and an onsubmit="retur n jcap()" function that invoked the
javascript; elsewhere in the page there was a call to another javascript
that implemented the image that needed to be verified. I would still like
to use that script to prevent autospammers. I am not sure how to call the
javascript function jcap() before the contactUS_Click event handler.

The event handler is server based, so I am hoping that I can just leave the
call in the form onsubmit attribute because I think that should fire first.

As for the email based script I am guessing that I should check the
page.IsPostback variable and excute it only when that is true.

Third:
I want to add some additional validation on form fields. Specifically I
would like to test for a valid email address if nothing else. I am planning
a form that has more data elements such as name, address, phone number, etc
that I expect to concatenate into the message body.

Fourth:
I want to convert the script from VB.NET to C#
' =============== =============== ==============
<% @Import Namespace="Syst em.Web.Mail" %>
<script language="vb" runat="server">

Sub contactUS_Click (sender as Object, e as EventArgs)

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

objMM.To = "in**@1and1.com "
objMM.From = email.Text

'If you want to CC this e-mail to someone else
'objMM.Cc = "su*****@1and1. com"

'e-mail format. Can be Text or Html
objMM.BodyForma t = MailFormat.Text

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

'Set the subject
objMM.Subject = "1&1 Contact US"

'Set the body
objMM.Body = message.Text

'Smtp Server
SmtpMail.SmtpSe rver = "mrelay.perfora .net"

'Send the message
SmtpMail.Send(o bjMM)

panelSendEmail. Visible = false
panelMailSent.V isible = true

End Sub

</script>

<html>
<body>
<asp:panel id="panelSendEm ail" runat="server">
<form runat="server">
<h2>CONTACT US FORM</h2>

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

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

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

<asp:button runat="server" id="contact_us " Text="Contact"
OnClick="contac tUS_Click" />
</form>
</asp:panel>
<asp:panel id="panelMailSe nt" runat="server" Visible="False" >
An e-mail has been sent. We will contact you soon!
</asp:panel>
</body>
</html>
Aug 16 '08 #1
5 2412
Note: Since I wrote this I learned that System.Web.Mail is deppricated
"Henry Stock" <he***@henry-stock.comwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
My ISP provides this sample for an ASP.NET capable email form.

If you have any idea about how to do the following, I would greatly
appreciate your help.

I have a few alterations that I would like to implement, but I am not sure
where to begin.

First:

I want to implement the code in a codebehind page instead of in the
mailform.aspx page. I am not sure where I would put the code. I also
know that there are differences in background operations between ASP.NET
1.1 and ASP.NET 2.0, but I don't know if the code would differ much. In
other stuff I found on the internet, the SMTP server was identified in a
<mailsettingsse ction in the web.config file. That seems cleaner to me,
but I don't know how the code would change. I probably would skip the code
identifying the server.

Second:

I already have an old mail form that was implemented using a CGI. I also
used a javascript based CAPTCHA function in that form to cut down on
automated spam.
In that instance the old form tag included and action attribute that
pointed to the cgi and an onsubmit="retur n jcap()" function that invoked
the javascript; elsewhere in the page there was a call to another
javascript that implemented the image that needed to be verified. I
would still like to use that script to prevent autospammers. I am not sure
how to call the javascript function jcap() before the contactUS_Click
event handler.

The event handler is server based, so I am hoping that I can just leave
the call in the form onsubmit attribute because I think that should fire
first.

As for the email based script I am guessing that I should check the
page.IsPostback variable and excute it only when that is true.

Third:
I want to add some additional validation on form fields. Specifically I
would like to test for a valid email address if nothing else. I am
planning a form that has more data elements such as name, address, phone
number, etc that I expect to concatenate into the message body.

Fourth:
I want to convert the script from VB.NET to C#
' =============== =============== ==============
<% @Import Namespace="Syst em.Web.Mail" %>
<script language="vb" runat="server">

Sub contactUS_Click (sender as Object, e as EventArgs)

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

objMM.To = "in**@1and1.com "
objMM.From = email.Text

'If you want to CC this e-mail to someone else
'objMM.Cc = "su*****@1and1. com"

'e-mail format. Can be Text or Html
objMM.BodyForma t = MailFormat.Text

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

'Set the subject
objMM.Subject = "1&1 Contact US"

'Set the body
objMM.Body = message.Text

'Smtp Server
SmtpMail.SmtpSe rver = "mrelay.perfora .net"

'Send the message
SmtpMail.Send(o bjMM)

panelSendEmail. Visible = false
panelMailSent.V isible = true

End Sub

</script>

<html>
<body>
<asp:panel id="panelSendEm ail" runat="server">
<form runat="server">
<h2>CONTACT US FORM</h2>

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

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

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

<asp:button runat="server" id="contact_us " Text="Contact"
OnClick="contac tUS_Click" />
</form>
</asp:panel>
<asp:panel id="panelMailSe nt" runat="server" Visible="False" >
An e-mail has been sent. We will contact you soon!
</asp:panel>
</body>
</html>


Aug 16 '08 #2
re:
!Note: Since I wrote this I learned that System.Web.Mail is deppricated

Not for ASP.NET 1.1 apps.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Henry Stock" <he***@henry-stock.comwrote in message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Note: Since I wrote this I learned that System.Web.Mail is deppricated
"Henry Stock" <he***@henry-stock.comwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
>My ISP provides this sample for an ASP.NET capable email form.

If you have any idea about how to do the following, I would greatly
appreciate your help.

I have a few alterations that I would like to implement, but I am not sure
where to begin.

First:

I want to implement the code in a codebehind page instead of in the
mailform.asp x page. I am not sure where I would put the code. I also
know that there are differences in background operations between ASP.NET
1.1 and ASP.NET 2.0, but I don't know if the code would differ much. In
other stuff I found on the internet, the SMTP server was identified in a
<mailsettingss ection in the web.config file. That seems cleaner to me,
but I don't know how the code would change. I probably would skip the code
identifying the server.

Second:

I already have an old mail form that was implemented using a CGI. I also
used a javascript based CAPTCHA function in that form to cut down on
automated spam.
In that instance the old form tag included and action attribute that
pointed to the cgi and an onsubmit="retur n jcap()" function that invoked
the javascript; elsewhere in the page there was a call to another
javascript that implemented the image that needed to be verified. I
would still like to use that script to prevent autospammers. I am not sure
how to call the javascript function jcap() before the contactUS_Click
event handler.

The event handler is server based, so I am hoping that I can just leave
the call in the form onsubmit attribute because I think that should fire
first.

As for the email based script I am guessing that I should check the
page.IsPostbac k variable and excute it only when that is true.

Third:
I want to add some additional validation on form fields. Specifically I
would like to test for a valid email address if nothing else. I am
planning a form that has more data elements such as name, address, phone
number, etc that I expect to concatenate into the message body.

Fourth:
I want to convert the script from VB.NET to C#
' =============== =============== ==============
<% @Import Namespace="Syst em.Web.Mail" %>
<script language="vb" runat="server">

Sub contactUS_Click (sender as Object, e as EventArgs)

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

objMM.To = "in**@1and1.com "
objMM.From = email.Text

'If you want to CC this e-mail to someone else
'objMM.Cc = "su*****@1and1. com"

'e-mail format. Can be Text or Html
objMM.BodyForma t = MailFormat.Text

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

'Set the subject
objMM.Subject = "1&1 Contact US"

'Set the body
objMM.Body = message.Text

'Smtp Server
SmtpMail.SmtpSe rver = "mrelay.perfora .net"

'Send the message
SmtpMail.Send(o bjMM)

panelSendEmail. Visible = false
panelMailSent.V isible = true

End Sub

</script>

<html>
<body>
<asp:panel id="panelSendEm ail" runat="server">
<form runat="server">
<h2>CONTACT US FORM</h2>

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

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

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

<asp:button runat="server" id="contact_us " Text="Contact"
OnClick="conta ctUS_Click" />
</form>
</asp:panel>
<asp:panel id="panelMailSe nt" runat="server" Visible="False" >
An e-mail has been sent. We will contact you soon!
</asp:panel>
</body>
</html>



Aug 16 '08 #3
"Henry Stock" <he***@henry-stock.comwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
My ISP provides this sample for an ASP.NET capable email form.
What version of ASP.NET is running on your ISP's webserver?
I want to implement the code in a codebehind page instead of in the
mailform.aspx page.
Why? Despite what some people will tell you, there is absolutely no benefit
whatsoever in doing this. In fact, many well-respected developers prefer
this type of inline coding for aspx pages, and only use class pages for
common / shared functionality.. .
I also know that there are differences in background operations between
ASP.NET 1.1 and ASP.NET 2.0
There are - that's why you need to find out which version your ISP is
running...
Specifically I would like to test for a valid email address
http://www.google.co.uk/search?sourc...ess+validation
I want to convert the script from VB.NET to C#
There are dozens of online converters - GIYF...

But the first thing is to find out what version of ASP.NET your ISP is
running...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 16 '08 #4
In answer to why use code behind page:
According to Microsoft it allows for cleaner separation of of code and
design issues.

I wasn't clear on that. Sorry. My ISP is running ASP.NET 2.0. which is
good for me. I am trying to use the newsest stuff my tools will support and
I have Visual Studio 2005

"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
"Henry Stock" <he***@henry-stock.comwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
>My ISP provides this sample for an ASP.NET capable email form.

What version of ASP.NET is running on your ISP's webserver?
>I want to implement the code in a codebehind page instead of in the
mailform.asp x page.

Why? Despite what some people will tell you, there is absolutely no
benefit whatsoever in doing this. In fact, many well-respected developers
prefer this type of inline coding for aspx pages, and only use class pages
for common / shared functionality.. .
>I also know that there are differences in background operations between
ASP.NET 1.1 and ASP.NET 2.0

There are - that's why you need to find out which version your ISP is
running...
>Specifically I would like to test for a valid email address

http://www.google.co.uk/search?sourc...ess+validation
>I want to convert the script from VB.NET to C#

There are dozens of online converters - GIYF...

But the first thing is to find out what version of ASP.NET your ISP is
running...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 16 '08 #5
"Henry Stock" <he***@henry-stock.comwrote in message
news:OO******** ******@TK2MSFTN GP03.phx.gbl...

[top-posting corrected]
>>I want to implement the code in a codebehind page instead of in the
mailform.as px page.

Why? Despite what some people will tell you, there is absolutely no
benefit whatsoever in doing this. In fact, many well-respected developers
prefer this type of inline coding for aspx pages, and only use class
pages for common / shared functionality.. .

In answer to why use code behind page:
According to Microsoft it allows for cleaner separation of of code and
design issues.
That is completely incorrect.
>There are - that's why you need to find out which version your ISP is
running...

I wasn't clear on that. Sorry. My ISP is running ASP.NET 2.0. which is
good for me. I am trying to use the newsest stuff my tools will support
and I have Visual Studio 2005
System.Net.Mail , then...
http://www.systemnetmail.com/
http://msdn.microsoft.com/en-us/libr...wc(VS.80).aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 16 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4227
by: pee2pee | last post by:
Hi, I have below code: <html> <head> <title>Contacting Worldpay, Please wait.......</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body text="#CCCCCC">
6
11184
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I will include the code I originally used. I understand I should switch from CDONTS to CDO mail but after several sttempts I am finding a very hard time getting the new CDO mail to work properly. Any assistance with this would be greatly...
30
9852
by: btober | last post by:
Whenever I create a temporary table, with something like CREATE TEMPORARY TABLE temptable1 AS SELECT * FROM paid.ad_hoc_query; New schemas appear, with names like "pg_temp_1". I guess the appearance of these schemas with "temp" in the name indicates that they are "temporary" schemas and related to the temporary table creation, but the schemas persist even after the end of the session in which the temporary table was created.
7
2171
by: GeorgeAtkins | last post by:
I want to create a web-based form or page that consists of a series of formatted questions and answers. The form will resemble an existing paper form. When the form is filled in, I want the user to submit the form via e-mail and have the complete form with answers sent, not just the data. That is, the recipient should be able to open the attachment and see (and print) the complete, formatted form. It seems to me that solutions simply...
0
9253
Ganon11
by: Ganon11 | last post by:
The Miscellaneous Discussions forum is for any technology related question, comment, concern, or discussion. However, we encourage you to look at the full list of forums before deciding this is the best place for your thread. For instance, a question about C/C++ technically fits into this forum, but it would be much better in our C/C++ forum. Just browse quickly through the list to see if we have a forum that would be more relevant to your...
1
3311
by: vinodkus | last post by:
Problem 1I m writing a mail program in asp my first page is mail.asp where I subitting address, subject, body and second page is send_mail.asp Contents of Page mail.asp <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document">
2
4557
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name) 2)To 3) Subject 4) Message5) File input(name abc) - to be sent as an attachment. This form calls the Class PhpMailer through another form with the following code to send the mail. <?php ini_set("include_path",...
3
3297
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using it's mail () function to send the mail. However, as I got more into that topic I realized that one should be really concerned about the validation part to prevent spam abuse. There are shiploads of 'mail scripts' available with each of them has...
0
9273
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5141
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.