<%@page language="VB" %>
<%@Import Namespace="System.Web.Util" %>
<HTML><BODY>
<SCRIPT LANGUAGE="VB" RUNAT="server">
' This method is called on the server when the submit
' button is clicked on the client and when the page
' posts back to itself
Sub SendMail (Obj As Object, E As EventArgs)
' Instantiate a MailMessage object. This serves as a message object
' on which we can set properties.
Dim mailObj AS new MailMessage
' Set the from and to address on the email
mailObj.From = Request.Form("From")
mailObj.To = Request.Form("To")
mailObj.Subject = "Subject Of the Mail"
mailObj.Body = "Body of the Mail"
' Optional: HTML format for the email
mailObj.BodyFormat = MailFormat.Html
' Optional: Encoding for the message
mailObj.BodyEncoding = MailFormat.Base64
' Optional: Set the priority of the message to high
mailObj.Priority = MailPriority.High
' Optional: Attach a file to the email.
' Note here that we have created a MailAttachment object to
' attach a file to the email
mailObj.Attachments.Add(new MailAttachment("c:\test.doc"))
' Send the email using the SmtpMail object
SmtpMail.Send(mailObj)
End Sub
</SCRIPT>
<asp:label ID="Headingmsg" Text="Enter Your Email Address:" RUNAT="server"/>
<FORM METHOD="post" RUNAT="server">
Email Recipient: <INPUT TYPE="text" NAME="to"> <br>
Email Sender: <INPUT TYPE="text" NAME="from">
<INPUT TYPE="submit" NAME="Submit" VALUE="Send Mail" RUNAT="server" OnServerClick="SendMail">
</FORM>
</BODY>
<%@page language="C#" %>
<%@Import Namespace="System.Web.Util" %>
<HTML><BODY>
<SCRIPT LANGUAGE="C#" RUNAT="server">
// This method is called on the server when the submit
// button is clicked on the client and when the page
// posts back to itself
public void SendMail (Object Obj, EventArgs E)
{
// Instantiate a MailMessage object. This serves as a message object
// on which we can set properties.
MailMessage mailObj = new MailMessage();
// Set the from and to address on the email
mailObj.From = Request.Form("From");
mailObj.To = Request.Form("To");
mailObj.Subject = "Subject Of the Mail";
mailObj.Body = "Body of the Mail";
// Optional: HTML format for the email
mailObj.BodyFormat = MailFormat.Html;
// Optional: Encoding for the message
mailObj.BodyEncoding = MailFormat.Base64;
// Optional: Set the priority of the message to high
mailObj.Priority = MailPriority.High;
// Optional: Attach a file to the email.
// Note here that we have created a MailAttachment object to
// attach a file to the email
mailObj.Attachments.Add(new MailAttachment("c:\\test.doc"));
// Send the email using the SmtpMail object
SmtpMail.Send(mailObj);
}
</SCRIPT>
<asp:label ID="Headingmsg" Text="Enter Your Email Address:" RUNAT="server"/>
<FORM METHOD="post" RUNAT="server">
Email Recipient: <INPUT TYPE="text" NAME="to"> <br>
Email Sender: <INPUT TYPE="text" NAME="from">
<INPUT TYPE="submit" NAME="Submit" VALUE="Send Mail" RUNAT="server" OnServerClick="SendMail">
</FORM>
</BODY>