• The eternal confessions of a beautiful mind...
  • DamianM.Co.UK
  • Home
  • About
  • Archives
  • Contact
  • Sitemap
  • My Flickr

    IMG_9585IMG_9115IMG_9113IMG_9111IMG_9078IMG_9075IMG_9069IMG_9065IMG_9041IMG_9032IMG_8963IMG_8928IMG_8916IMG_8915IMG_8904IMG_8876IMG_8858IMG_8830IMG_8828IMG_8826

  • Recent Posts

    • New Ohio Roller Coaster - INSANE!!!
    • Speeding
    • Captions not required
    • Unfortunate Backgrounds
    • Unfortunate Signs
    • OMG!!
    • Women as explained by engineer
    • The Monty Hall Problem
    • ahhh still love them - Motivational Posters
    • What does Mona Lisa do when the Museum is closed………
    • 21st Century kids books
    • Cool Origami
    • AWESOME Pictures!
    • Things you shouldn’t find in your vegetable patch!
    • World’s Best Graffiti…?
  • My Tools

    • Blog_LinkIt
    • DCoda Theme
    • DCoda Widgets
    • RSS_Sticky
    • WordPress.org
    • WP_BlogNetworking
    • WP_BlogRollSync
    • WP_BoilerPlate
    • WP_Censor
    • WP_ContactMe
    • WP_DeliciousPost
    • WP_EasyReply
    • WP_HeadNFoot
    • WP_LinkIt
    • WP_OneInstall
    • WP_PostDate
    • WP_PostNotes
    • WP_RssSticky
    • WP_Spoiler
    • WP_Submission
  • My Web

    • ASPAlliance
    • ClaimID
    • del.ico.us
    • Digg
    • DSLRBlog
    • DVDProfiler
    • Flickr
    • Honeyed SPAM
    • My Blog
    • My company
    • MYSpace
    • WordPress.org
    • YouTube

    Email

    .aspx

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    <%@ Control Language="vb" AutoEventWireup="false" Codebehind="email.ascx.vb" Inherits="DamianM.email" %>
    <form id="Form1" method="post" runat="server">
    	<Table id="Table1" width="100%">
    		<tr runat="server" id="mailRow">
    			<td width="50%" align="right">Enter Email Address : &nbsp;</td>
    			<td>
    				<asp:TextBox id="Eaddress" runat="server"></asp:TextBox>
    			</td>
    			<td>&nbsp;
    				<asp:Button id="Button1" runat="server" Text="Send Mail"></asp:Button></td>
    			<td width="50%"></td>
    		</tr>
    	</Table>
    </form>

    Email.aspx.vb

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    
    Imports System.Web
    Public Class email
        Inherits System.Web.UI.UserControl
        Protected WithEvents Button1 As System.Web.UI.WebControls.Button
        Protected WithEvents Eaddress As System.Web.UI.WebControls.TextBox
        Protected WithEvents sorryRow As System.Web.UI.HtmlControls.HtmlTableRow
        Protected WithEvents mailRow As System.Web.UI.HtmlControls.HtmlTableRow
     
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Page.IsPostBack Then
                'mail message objects
                Dim m As New System.Web.Mail.MailMessage()
     
                'smtp mail object need only defined if you with to
                Dim s As System.Web.Mail.SmtpMail
     
                'all mail properties are accessable through the mail message objects
                m.From = "Doable .Net"
                m.To = Eaddress.Text
                m.Subject = "Email in .net code sample"
                m.Body = "Thank you for your interest, see attached code sample."
                m.Priority = Mail.MailPriority.High
                'to make an attachment you need to create a mailattachment object
                Dim a As New System.Web.Mail.MailAttachment(Server.MapPath("/code/5/email.ascx"))
                'attach the atachment to the mail
                m.Attachments.Add(a)
     
                a = New System.Web.Mail.MailAttachment(Server.MapPath("/code/5/email.ascx.vb"))
                m.Attachments.Add(a)
     
                'designate the smtp server if required
                'but here we are using the web servers smtp service
                '
                's.SmtpServer = "mail.xxxxxxx.com"
     
                'send the mail
                s.Send(m)
     
            End If
     
        End Sub
    End Class

    Leave a Reply

    Related Posts from the Past:

    • Contact
    • Simple SMTP mailing with .NET
    • POP3 Email