Sending E-mails from an ASP.NET 1.1 page

Requirement: ASP.NET 1.1 Framework

Lot of customers have been regularly asking me how to properly send e-mails from an ASP.NET application. My server requires authentication and hence people are confused about the code which has to be given. The required code is given below for your reference. You just need to copy them and paste it into your ASP.NET page. That’s it.

I’ve implemented validation controls as well so you need not have to worry about incomplete submissions. You need to sometimes manually upload aspnet_client folder if you use a remote server.

I’ve also given the required code for SMTP authentication

Please note that domainname equals your domain followed by prefix (Example:
************ SOURCE CODE STARTS HERE ************

<%@ Page Language=”VB” %>
<%@ Import Namespace=”System.Web.Mail” %>
<script runat=”server”>   

   Sub btnSubmit_Click(sender as object, e as EventArgs)

  Dim objEmail as New MailMessage()
  objEmail.To = “YOUR E-MAIL ADDRESS”
                objEmail.From = txtFrom.Text
  objEmail.Subject = “Test Email”
  objEmail.Body = txtComments.Text & vbcrlf &vbcrlf &txtComments.Text
  objEmail.Priority = MailPriority.High
  objEmail.Fields.Add(““, “1”)
  objEmail.Fields.Add(““, “username@domainname“)
     objEmail.Fields.Add(““, “YOUR PASSWORD”)
     SmtpMail.SmtpServer = “mail.domainname”

  catch exc as Exception
   Response.Write(“Send failure: ” + exc.ToString())
  End Try
    End Sub

 <title>Sending E-mails with ASP.NET 1.1 Framework</title>
  <form runat=”server”>
                <div align=”left”>
                <table border=”0″ width=”544″>
      <td valign=”top”><font face=”Verdana” size=”2″>Name:</font></td>
      <td height=”24″>   <asp:TextBox runat=”server” Height=”25px” Width=”370px” ID=”txtName”></asp:TextBox>
      <asp:RequiredFieldValidator ID = “req1” ControlToValidate = “txtName” Runat = “server” ErrorMessage = “Please enter your name”></asp:RequiredFieldValidator></td>
      <td valign=”top”><font face=”Verdana” size=”2″>From</font></td>
      <td height=”24″> <asp:TextBox runat=”server” Height=”22px” Width=”368px” ID=”txtFrom”></asp:TextBox>
      <asp:RegularExpressionValidator ID = “reg1” ControlToValidate = “txtFrom” Runat = “server” ErrorMessage = “Invalid Email” ValidationExpression=”\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”></asp:RegularExpressionValidator>&nbsp;<asp:RequiredFieldValidator ID = “req3” ControlToValidate = “txtFrom” Runat = “server” ErrorMessage = “Please enter your E-mail” ></asp:RequiredFieldValidator></td>
      <td valign=”top”><font face=”Verdana” size=”2″>Comments:</font></td>
      <td height=”112″> <asp:TextBox runat=”server” Height=”110px” TextMode=”MultiLine” Width=”368px” ID=”txtComments”></asp:TextBox>
      <asp:RequiredFieldValidator ID = “req2” ControlToValidate = “txtComments” Runat = “server” ErrorMessage = “Please enter your comments”></asp:RequiredFieldValidator>
      <td colspan=”2″ valign=”top” height=”30″>
      <p align=”center”>

   <asp:Button Runat = server ID = btnSubmit OnClick = btnSubmit_Click Text = “Submit”></asp:Button>
      &nbsp;<input type = “reset” runat = “server” value = “Clear”></td>

   <!– Insert content here –>

************ SOURCE CODE ENDS HERE ************

I hope the code will help you to implement email functionality through an ASP.NET page. You need not have to worry about SPAMS as users will never know to which email they are sending e-mail.

Review – Media Player 11

Today, I installed Windows Media Player 11 and it took more than 10 minutes as it installed some add-ons such as URGE. It’s an online music shopping site plugins. I am amazed to see that the whole interface has been completely modified and sports a new look and feel in black color. The media library is very well organized as compared to its previous versions.

An interesting point to note is that you can now RIP a CD using Media Player. I was planning to rip some CD songs using a third party tool but with this new mdia player I can do it easily. I can experience the real working of the product only if I use it for some time as this version is a beta stuff. I believe that Microsoft will include the full version along with Windows Vista in December. Microsoft is really working hard to provide quality product for its customers.

Windows Vista and Community Server 2.1

For the last few days, I’m wondering whether CS 2.1 will be compatible with Windows Vista for using the product  locally or for development purposes. Well. I’m planning to install the software and will observe the result.