ASPAlliance.com : The #1 Active Server Pages .NET Community The #1 ASP.NET Community
Search   Search

Subscribe   Subscribe

Powered by ORCSWeb Hosting


Site Stats


Powered By ASP.NET
 
Featured Sponsor

Featured Columnist


Featured Book
Sams Teach Yourself C# Web Programming in 21 Days
Sams Teach Yourself C# Web Programming in 21 Days

Find Prices
Sample Chapter


New! asp.netPRO

We publish our articles in the standard RSS format.

Powerful .NET Email Component

Code Sharing Software
Email.aspx.vb by Damian Manifold
  1 public class email
  2     Inherits System.Web.UI.Page
  3     protected WithEvents Button1 as System.Web.UI.WebControls.Button
  4     protected WithEvents Eaddress as System.Web.UI.WebControls.TextBox
  5     protected WithEvents sorryRow as System.Web.UI.HtmlControls.HtmlTableRow
  6     protected WithEvents Alliance1 as DPM.Alliance
  7     protected WithEvents Alliance2 as DPM.Alliance
  8     protected WithEvents mailRow as System.Web.UI.HtmlControls.HtmlTableRow
  9 
  10     private Sub Page_Load(ByVal sender as System.objectByVal e as System.EventArgs) Handles MyBase.Load
  11 
  12         '--a little cookie code to stop abuse of the mail
  13         if Request.Cookies("mail") is Nothing Then
  14             sorryRow.Visible = false
  15             mailRow.Visible = true
  16         else
  17             sorryRow.Visible = true
  18             mailRow.Visible = false
  19         End if
  20 
  21 
  22         if Page.IsPostBack Then
  23             'mail message objects
  24             Dim m as new System.Web.Mail.MailMessage()
  25 
  26             'smtp mail object need only defined if you with to
  27             Dim s as System.Web.Mail.SmtpMail
  28 
  29             'all mail properties are accessable through the mail message objects
  30             m.From = "Doable .Net"
  31             m.To = Eaddress.Text
  32             m.Subject = "Email in .net code sample"
  33             m.Body = "Thank you for your interest, see attached code sample."
  34             m.Priority = Mail.MailPriority.High
  35             'to make an attachment you need to create a mailattachment object
  36             Dim a as new System.Web.Mail.MailAttachment(Server.MapPath("email.aspx"))
  37             'attach the atachment to the mail
  38             m.Attachments.Add(a)
  39 
  40             a = new System.Web.Mail.MailAttachment(Server.MapPath("email.aspx.vb"))
  41             m.Attachments.Add(a)
  42 
  43             'designate the smtp server if required
  44             'but her we are using the web servers smtp serice
  45             '
  46             's.SmtpServer = "mail.xxxxxxx.com"
  47 
  48             'send the mail
  49             s.Send(m)
  50 
  51             '-- set the antispam cookie
  52             Dim c as new System.Web.HttpCookie("Mail")
  53             c.Value = "disable"
  54             c.Expires = Now().AddMinutes(1)
  55             Response.Cookies.Add(c)
  56             Response.Redirect("http://aspalliance.com/damianm/article1/2/")
  57         End if
  58 
  59     End Sub
  60 
  61     private Sub InitializeComponent()
  62 
  63     End Sub
  64 End class
Email.aspx.vbGenerated using CodeView
 Copyright © 2000-2003 ASPAlliance.com  Page Rendered at 11/7/2009 8:10:38 PM