Code sniplet on sending email via ASP.NET in html format.Below is code that can be used to send html formatted email using ASP.NET
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="False" Strict="True" %><%@ Import Namespace="System.Web.Mail" %> <SCRIPT language=VB runat="server"> Sub Page_load(Sender as Object, E as EventArgs)
If request.form("EmailAddress") = "" Then dim strResponse as string = "<h2>Send Email using ASP.NET formatted in HTML</h2>" lblMessage.Text = strResponse Else dim strResponse as string = "You just sent an email message formatted in HTML to: <h2>" & request("EmailAddress") & "</h2>" lblMessage.Text = strResponse End If End Sub Sub btn_Click(sender as Object, e as System.EventArgs)
If request.form("EmailAddress") <> "" Dim mail As New MailMessage mail.From = "youraddress@domain.com" mail.To = request.form("EmailAddress") mail.Subject = "Message sent using ASP.NET and CDONTS" mail.Body = "HTML Message sent from ASPFree.com using ASP.NET and Cdonts <a href='http://aspfree.com/aspnet/email.aspx'>Wonder how this is done?</a>
<a href='http://aspfree.com/aspnet/setupcdonts.aspx'>Wonder How to setup CDONTS?</a>" mail.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = "LocalServerName" SmtpMail.Send(mail) End If End Sub
</SCRIPT>
<H1 align=center>Sending Email via ASP.NET and CDONTS..</H1><B><A href="/aspnet/setupcdonts.aspx">How do I setup my server to use CDONTS?</A></B>
<A href="/allzips/emaildotnet.zip"><IMG src="http://aspfree.com/images/downloadcode.gif" border=0></A>
<asp:Label id=lblMessage runat="server" BorderColor="#cccccc" BorderStyle="solid" Width="400px" Font-Name="Verdana"></asp:Label> <FORM name=form1 method=post runat="server">Email Address:<INPUT style="BACKGROUND-COLOR: #ffffa0" size=30 name=EmailAddress>
<INPUT id=btnSubmit type=submit value="Sending Email with ASP.NET" name=b1 runat="server" OnServerClick="btn_Click"> </FORM>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications. FREE! Go There Now!
| | | | IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points. FREE! Go There Now!
| | | | As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change. FREE! Go There Now!
| | | | Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually. FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
| | | | Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise. FREE! Go There Now!
| | | | WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
| | | | You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |