有什么办法可以自动将整个表格的内容邮寄到Gmail帐户

有什么办法可以自动将整个表格的内容邮寄到Gmail帐户

本文介绍了有什么办法可以自动将整个表格的内容邮寄到Gmail帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请尽快帮助我.我也想要源代码.请

Please help me as soon as possible. I want the source code too. Please

推荐答案

protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            string userinfo;
            string noDetails = "-Not Provided-";
            string email;
            SmtpClient smtpClient = new SmtpClient();
            MailMessage message = new MailMessage();
            MailAddress fromAddress = new MailAddress(txtEmail.Text);
            //Client webmail
            smtpClient.Host = "smtp.1and1.com";
            smtpClient.Port = 25;
            smtpClient.Credentials = new NetworkCredential("username", "password");
            smtpClient.EnableSsl = true;
            message.From = fromAddress;
            //PHW email-id
            message.To.Add("username ");

           
            message.Subject = "Registration Requisition";
            message.IsBodyHtml = true;

            userinfo = "<b>" + "<div>" + "<u>" + "School Information" + "</u>" + "</div>" + "</b>" + "<br>" +
                        "<table border='1' bordercolor='#BD213A' bordercolordark='#BD213A' bordercolorlight='#0092DD'>" +

                        "<tr>" +
                        "<td style='width: 131px'>" +
                            "School Name" + "</td>" +
                        "<td style=width: 250px>" +
                            txtFirstName.Text  + " </td>" +
                        "</tr>" +

                        "<tr>" +
                        "<td style='width: 131px'>" +
                            "First Name " + "</td>" +
                        "<td style=width: 250px>" +
                            txtLastName.Text  + " </td>" +
                        "</tr>" +

                        "<tr>" +
                        "<td style='width: 131px'>" +
                            "Last Name " + "</td>" +
                        "<td style=width: 250px>" +
                            TextBox1 .Text + " </td>" +
                        "</tr>" +

                       "<tr>" +
                        "<td style='width: 131px' >" +
                            "City" + "</td>" +
                        "<td style='width: 250px'>" +
                            txtCity.Text + "</td>" +
                        "</tr>" +

                         "<tr>" +
                        "<td style='width: 131px' >" +
                            "Country" + "</td>" +
                        "<td style='width: 250px'>" +
                            dd1Country.SelectedItem.Text + "</td>" +
                        "</tr>" +
                         "<tr>" +
                        "<td style='width: 131px' >" +
                            "Phone" + "</td>" +
                        "<td style='width: 250px'>" +
                            txtPhone.Text + "</td>" +
                        "</tr>" +
                         "<tr>" +
                        "<td style='width: 131px' >" +
                            "Zipcode" + "</td>" +
                        "<td style='width: 250px'>" +
                            txtZip.Text + "</td>" +
                        "</tr>" +
                        "<tr>" +
                        "<td style='width: 131px' >" +
                            "Email" + "</td>" +
                        "<td style='width: 250px'>" +
                            txtEmail.Text + "</td>" +
                        "</tr>" +
                        "</table>";

            message.Body = userinfo;
            message.Body = string.Concat(userinfo);
            smtpClient.Send(message);
            beforereg.Visible = false;
            Confirmpnl.Visible = true;
            this.Response.AppendHeader("Refresh", @"8;url='Default.aspx'");
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    private string StripHTML(string source)
    {
        try
        {
            string result;
            // Replaces all line breaks with the <BR> tag
            result = source.Replace("\r\n", "<br>");
            return result;
        }
        catch
        {
            Console.WriteLine("Error");
            return source;
        }
    }


这篇关于有什么办法可以自动将整个表格的内容邮寄到Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 18:45