Click here to Skip to main content
15,896,278 members
Articles / Web Development / ASP.NET

A Web based SMTP client program

Rate me:
Please Sign up or sign in to vote.
4.73/5 (11 votes)
13 Sep 20013 min read 307.5K   2.3K   73  
This is a a web based SMTP client program that can be used to send an email through a SMTP server.
<%@ 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" >&nbsp;</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" >&nbsp;</td>
<td width="70%" align="left" valign="middle">Developer:&nbsp;
<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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
MCSD.NET IT Professional with over 11 years of experience.Worked at various levels as Business Analyst, Technical Architect, System Analyst and Developer.


Comments and Discussions