Sending EMail Microsoft SMTP Service Simple Mail Transport
- Slides: 6
Sending E-Mail
Microsoft SMTP Service Simple Mail Transport Protocol Does not support the Post Office Protocol (POP) Inet. PubMail. RootPickup Send e-mail Inet. PubMail. RootDrop receive e-mail
Sending a Simple E-Mail Message <%@ Import Namespace="System. Web. Mail" %> <Script runat="Server"> Sub Button_Click( s As Object, e As Event. Args ) Smtp. Mail. Send( _ mailfrom. Text, _ mailto. Text, _ mailsubject. Text, _ mailbody. Text ) End Sub </Script>
Sending a Simple E-Mail Message <html> <head><title>Send. Mail. aspx</title></head> <body> <h 1>Send Mail: </h 1> <form runat="Server"> <b>From: </b> <asp: Text. Box ID="mailfrom" Columns="50" Runat="Server" /> <p> <b>To: </b> <asp: Text. Box ID="mailto" Columns="50" Runat="Server" /> <p> <b>Subject: </b> <asp: Text. Box ID="mailsubject" Columns="50" Runat="Server" /> <p> <b>Body: </b> <asp: Text. Box ID="mailbody" Text. Mode="Multiline" Columns="50" Rows="10" Runat="Server" /> <p> <asp: Button Text="Send!" On. Click="Button_Click" Runat="Server" /> </form> </body> </html>
Adding Attachments <%@ Import Namespace="System. Web. Mail" %> <% Dim obj. Mail. Message As Mail. Message Dim obj. Mail. Attachment As Mail. Attachment ' Create the Mail Attachment obj. Mail. Attachment = New Mail. Attachment( "c: Biz. Plan. doc" ) ' Create the Mail Message obj. Mail. Message = New Mail. Message obj. Mail. Message. From = "you@somewhere. com" obj. Mail. Message. To = "joe@somewhere. com" obj. Mail. Message. Subject = "Secret Business Plan" obj. Mail. Message. Body = "Here's the plan (don't show it to anyone!)" obj. Mail. Message. Attachments. Add( obj. Mail. Attachment ) ' Send the Mail Message Smtp. Mail. Send( obj. Mail. Message ) %> Biz. Plan Sent!
Sending HTML E-Mail <%@ Import Namespace="System. Web. Mail" %> <% Dim obj. Mail. Message As Mail. Message Dim str. HTMLBody As String ' Create the HTML Message Body str. HTMLBody = "<html><head>" & _ "<title>Thank You!</title>" & _ "</head><body bgcolor=lightblue>" & _ "<font face=Script size=6>" & _ "Thank you for registering!" & _ "</font></body></html>" ' Create the Mail Message obj. Mail. Message = New Mail. Message obj. Mail. Message. From = "you@somewhere. com" obj. Mail. Message. To = "joe@somewhere. com" obj. Mail. Message. Subject = "Thanks for Registering!" obj. Mail. Message. Body = str. HTMLBody obj. Mail. Message. Body. Format = Mail. Format. HTML ' Send the Mail Message Smtp. Mail. Send( obj. Mail. Message ) %> HTML Email Sent!