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 add two numbers in Android Studio? | Source Code
- FindViewByID returns null in android studio -SOLVED
- Saving changes is not permitted in SQL SERVER - [SOLVED]
- Restore of database failed. File cannot be restored over the existing. -[SOLVED]
- One or more projects in the solution were not loaded correctly in Visual Studio 2019 | FIXED
- How to find Laptop's Battery Health?
- SOLVED-Related Field got invalid lookup: icontains error in Django
- How to enable Search Feature in Django admin?
Related Article