Send Email using ASP.NET formatted in HTML

Code sniplet on sending email via ASP.NET in html format.

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 208
June 01, 2003
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement
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 Objectas 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 Objectas 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>

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials