mail integratin in c#

#region MailIntegration
    private void mailsent()
    {
        try
        {
            GetApplicationId();

            using (MailMessage mm = new MailMessage("shyam@rcm.ac.in", txtEmail.Text.Trim()))
            {
                mm.Subject = "Congratulations! Your application is submitted";

                #region BodySetup


                string body = "";
                body += "Dear " + txtYourName.Text.Trim()+" , ";//"jyoti.p@kencloud.co.in";;

                body += "<br /><br />This is a confirmation email that we are in receipt of your application for admission session –" + DateTime.Now.Year + " for ";
                body+=" "+ddlCourseApply.SelectedValue+".Your application ID is "+ViewState["Application_ID"]+ ""  ;
                     // <Course ex. BBA – Bachelors in Business Administration>/ BCA – Bachelors in Computer Application / MATA – Master Arts in Tourism Administration / PGDM – Post Graduate Diploma in Management>. Your application ID is <Application_ID>."



                body += "<br /><br />Our Admissions team will be in touch with you shortly. Alternatively you can reach us at +91-9090080841, +91-9437493666 (PGDM) or +91-9090080888.";
                    //"jyoti.p@kencloud.co.in";;

                body += "<br /><br />Our functioning hours for admissions department are Monday to Saturday from 8:30 AM to 6:00 PM. Thanking you for your interest in Regional College of Management.";

                body += "<br /><br />Thanks, ";
                body += "<br /><br /><b>Admissions Department</b>";
                body += "<br />Regional College of Management";
           

                body += "<html><body><img src='http://rcm.ac.in/images/rcm-logo.png'/></body></html>";
                body += "<br />---------------------------------------------------------------------------";
                body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
                #endregion
                mm.Body = body;

                mm.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential("shyam@rcm.ac.in", "shyam@1234");
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Port = 587;
                smtp.Send(mm);
                // ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
            }
        }
        catch (Exception ex)
        {

        }
    }
    private void SendMail()
    {
        string Froms = "shyam@rcm.ac.in";
        string Tos = "jyoti.p@kencloud.co.in";//txtEmail.Text.Trim();
        string UserName = string.Empty;
        string url = string.Empty;


        MailMessage msg = new MailMessage();
        msg.To.Add(new MailAddress(Tos, "jyoti.p@kencloud.co.in"));
        msg.From = new MailAddress(Froms, "RCM");
        msg.Subject = "RCM Application Form Submitted";

        #region BodySetup

        string body = "";
        body += "Hi, " + txtEmail.Text.Trim();

        body += "<br /><br />Thank you, for  RCM Registration Portal.";

        //   body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";

        // body += "<br /><br />To Complete Your Registration and verify your email please use the following link";

        // body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
        // body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";

        body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
        body += "<br /><b>OR</b>";
        //body += "<br />" + otpmsg + "</b>";
        body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
        body += "<br /><br /> Best Wishes,";
        body += "<br />SBackend Team";

        body += "<html><body><img src='http://rcm.ac.in/images/rcm-logo.png'/></body></html>";
        body += "<br />---------------------------------------------------------------------------";
        body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
        #endregion
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";

        smtp.EnableSsl = true;

        System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();

        NetworkCred.UserName = "shyam@rcm.ac.in";

        NetworkCred.Password = "shyam@1234";

        smtp.UseDefaultCredentials = true;

        smtp.Credentials = NetworkCred;

        smtp.Port = 587;

        //smtp.Send(mm);

        //msg.IsBodyHtml = false;
        //SmtpClient smtp = new SmtpClient();
        //smtp.Host = "smtp.gmail.com";
        ////smtp.EnableSsl = true;
        //NetworkCredential NetworkCred = new NetworkCredential("shyam@rcm.ac.in", "shyam@1234");
        //smtp.UseDefaultCredentials = true;
        //smtp.Credentials = NetworkCred;
        //smtp.Port = 587;
        //smtp.Send(msg);

        //  msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
        //  msg.IsBodyHtml = true;
        //  SmtpClient client = new SmtpClient();
        //  client.UseDefaultCredentials = false;
        //  //client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "chuma@1234");
        //  client.Credentials = new System.Net.NetworkCredential("shyam@rcm.ac.in", "shyam@1234");
        //  client.Port = 25;
        //  client.Host = "smtpout.secureserver.net";
        //  client.DeliveryMethod = SmtpDeliveryMethod.Network;
        ////  client.EnableSsl = true;
        try
        {
            smtp.Send(msg);
        }
        catch (Exception ex)
        {
        }

    }


    #endregion

Comments

Popular posts from this blog

Create Schema Using C# Asp .Net Dynamically.

How to post image in blob using Windows Azure.

How to set Transaction and Roll Back using Entity Framework in C# Code.