|
<%@ Import NameSpace="Ravindra" %>
<Script language="C#" runat="server">
void btnSend_Click(Object Sender,EventArgs e)
{
if(Page.IsPostBack)
{
SMTPMail smail = new SMTPMail() ; ;
�smail.MailFrom = txtfrom.Text ;
smail.MailTo = txtto.Text ;
smail.MailData = txtmessage.Text ;
smail.Subject = txtSubject.Text ;
smail.SMTPServerIP = txtSMTPServerIP.Text ;
smail.SendMail();
if (smail.ErrorMessage!="")
{
Response.Write("Error: " + smail.ErrorMessage) ;
�}
else
{
/*
for debugging only.
Response.Write(smail.ServerResponse + "Mail Sent successfully") ;
*/
Response.Write("<br>Mail Sent successfully<br>") ;�
�}
}
}
</script>
<html>
<head>
<title>SMTP E-Mail Example by Ravindra Sadaphule
</title>
</head>
<body>
<form name="frm1" runat="server">
<table width="100%">
<tr>
<td colspan="2" align="center"><h3>SMTP MAIL </h3></td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" >SMTP SERVER IP:</td>
<td width="70%" align="left" valign="middle" >
<asp:textbox id="txtSMTPServerIP" runat="server" />e.g. 127.0.0.1
</td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" >
From:
</td>
<td width="70%" align="left" valign="middle" >
<asp:textbox id="txtfrom" runat="server" />e.g. ravi_sadaphule@hotmail.com
</td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" >
To:
</td>
<td width="70%" align="left" valign="middle" >
<asp:textbox id="txtto" runat="server" />e.g. tarunt@bharat.com
</td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" >
Sub:
</td>
<td width="50%" align="left" valign="middle" >
<asp:textbox id="txtSubject" runat="server" />e.g. Marriage Proposal
</td>
</tr>
<tr>
<td width= "30%"align="center"valign="middle" >
Message:
</td>
<td width="70%" align="left" valign="middle" >
<asp:textbox id="txtmessage" TextMode="MultiLine" Rows="5" runat="server" />
</td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" > </td>
<td width="70%" align="left" valign="middle" >
<asp:button text="Send Mail" id="btnSend" OnClick="btnSend_Click" runat="server" />
</td>
</tr>
<tr>
<td width="30%" align="center" valign="middle" > </td>
<td width="70%" align="left" valign="middle">Developer:
<a href="mailto:ravi_sadaphule@hotmail.com"> Ravindra Sadaphule</a>
</td>
</tr>
</table>
</form>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
MCSD.NET IT Professional with over 11 years of experience.Worked at various levels as Business Analyst, Technical Architect, System Analyst and Developer.