In this article I will show you how to send email using asp.net c#. You need to configure the yahoo mail smtp server in SmtpClient class from the namespace System.Net.Mail.
HTML Markup:
<form id="form1" runat="server">
<div>
<table>
<tr>
<th colspan="2">Sending Mails using Yahoo...!!!
</th>
</tr>
<tr>
<td style="width: 40px;">To : </td>
<td>
<asp:TextBox ID="txtEmailId" runat="server" Width="310px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txt_msg" runat="server" TextMode="MultiLine" Height="149px"
Width="329px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="sentmail" runat="server"
Text="Sending Mail using Yahoo" OnClick=" btnSentMail" /></td>
</tr>
</table>
</div>
</form>
C# coding:
protected void btnSentMail(object sender, EventArgs e)
{
MailMessage ms = new MailMessage("your yahoomail id", txtEmailId.Text);
ms.Subject = "Testing Sending Mail through Yahoo";
ms.Body = txt_msg.Text;
ms.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com", 587);
smtp.Credentials = new System.Net.NetworkCredential("your yahoomail id ", "your password");
smtp.EnableSsl = true;
smtp.Send(ms);
}
If you’re getting error “smtp server requires a secure connection 5.5.1”. It will be resolved by the following way click SMTP server requires a secure connection or the client was not authenticated
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article