HOW TO SEND EMAIL FROM ZOHO MAIL SMTP SERVER IN ASP.NET

in programming •  6 years ago 

HERE IN THIS ASP.NET Tutorial  WE WILL USE  TO SEND EMAIL FROM ZOHO MAIL SMTP SERVER IN ASP.NET

HERE WE REQUIRED 

LABEL CONTROL

TEXTBOX CONTROL

ZOHO MAIL ACCOUNT

Host :- smtp.zoho.com

Port :- 587

EnableSsl :-true

NetworkCredential :- "EmailId" And "Password" Of Zoho Mail

Step 1:-Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

    <style type="text/css">

        .style1

        {

            width: 93px;

        }

        .style2

        {

            width: 74px;

        }

    </style>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    

        <table style="width: 41%; height: 57px;">

            <tr>

                <td class="style1">

                    <asp:Label ID="Label1" runat="server" Text="To :"></asp:Label>

                </td>

                <td class="style2">

                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

                </td>

                <td>

                    &nbsp;</td>

            </tr>

            <tr>

                <td class="style1">

                    <asp:Label ID="Label2" runat="server" Text="From :"></asp:Label>

                </td>

                <td class="style2">

                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

                </td>

                <td>

                    &nbsp;</td>

            </tr>

            <tr>

                <td class="style1">

                    &nbsp;</td>

                <td class="style2">

                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />

                </td>

                <td>

                    &nbsp;</td>

            </tr>

            <tr>

                <td class="style1">

                    &nbsp;</td>

                <td class="style2">

                    <asp:Label ID="Label3" runat="server" ForeColor="Lime"></asp:Label>

                </td>

                <td>

                    &nbsp;</td>

            </tr>

        </table>

    

    </div>

    </form>

</body>

</html>

Step 2:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Net.Mail;

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void Button1_Click(object sender, EventArgs e)

    {

        try

        {

            MailMessage message = new System.Net.Mail.MailMessage(TextBox1.Text, TextBox2.Text);

            message.Subject = "Hi My Name Is Viraj..........";

            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.zoho.com";

            smtp.Port = 587;

            smtp.Credentials = new System.Net.NetworkCredential("youremailid","yourpassword");

            smtp.EnableSsl = true;

            message.IsBodyHtml = true;

            smtp.Send(message);

            Label3.Text = "Mail Send";

        }

        catch (Exception ex)

        {

            Console.Write(ex.Message);

            Label3.Text = "Mail Send Failed";

        }

    }

}


Video Related To Topic



If You Haven't Subscribers My Channel Than Please Subscribers It And Even Share It Link Of My Channnel :- https://www.youtube.com/channel/UCdIDIGUh3rL9A_Yt_tbZmkg Please Go And Subscribers It

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

If You Haven't Subscribers My Channel Than Please Subscribers It And Even Share It Link Of My Channnel :- https://www.youtube.com/channel/UCdIDIGUh3rL9A_Yt_tbZmkg Please Go And Subscribers It