返回首页

亲爱的朋友们,请告诉我如何发送TextBox1的*,TextBox2中,textbox3 *,textbox4,textbox5,textbox6。(*必须填写)

在submit_click-GT,它发送所有文本字段直接到Gmail帐户

我在此试图从很长的日子,所以请告诉我,机智详细代码和解释。对不起,如果我期待这种形式更像询问详细的代码和解释时,我的朋友都是免费的,请考虑我的请求

谢谢支持

现在我有STUCKUP这里请帮助我请请......

这是我"这一消息可能尚未发出的错误:karthikh87@gmail.com了解更多信息报告网络钓鱼"请帮我解决这个问题和代码如下所示:

using System;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Net.Mail;

 

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

{

      #region   "Send email"

      protected void btnSendmail_Click(object sender, EventArgs e)

      {

            // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0

            // System.Net.Mail.SmtpClient is the alternate class for this in 2.0

            SmtpClient smtpClient = new SmtpClient();

            MailMessage message = new MailMessage();

 

            try

            {

                  MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

 

                  // You can specify the host name or ipaddress of your server

                  // Default in IIS will be localhost 

                  smtpClient.Host = "localhost";

 

                  //Default port will be 25

                  smtpClient.Port = 25;

 

                  //From address will be given as a MailAddress Object

                  message.From = fromAddress;

 

                  // To address collection of MailAddress

                  message.To.Add("karthikh87@gmail.com");

                  message.Subject = "Feedback";

 

                  // CC and BCC optional

                  // MailAddressCollection class is used to send the email to various users

                  // You can specify Address as new MailAddress("admin1@yoursite.com")

                  message.CC.Add("karthikh87@gmail.com");

                  message.CC.Add("karthikh87@gmail.com");

 

                  // You can specify Address directly as string

                  message.Bcc.Add(new MailAddress("karthikh87@gmail.com"));

                  message.Bcc.Add(new MailAddress("karthikh87@gmail.com"));

 

                  //Body can be Html or text format

                  //Specify true if it   is html message

                  message.IsBodyHtml = false;

 

                  // Message body content

                  message.Body = txtMessage.Text;

            

                  // Send SMTP mail

                  smtpClient.Send(message);

 

                  lblStatus.Text = "Email successfully sent.";

            }

            catch (Exception ex)

            {

                  lblStatus.Text = "Send Email Failed.<br>" + ex.Message;

            }

            Response.Redirect("index.html");

      }

      #endregion

 

      #region "Reset"

      protected void btnReset_Click(object sender, EventArgs e)

      {

            txtName.Text = "";

            txtMessage.Text = "";

            txtEmail.Text = "";

      }

      #endregion

}

回答

评论会员:游客 时间:2012/02/07
在这里看到,它提供了一个通用电子邮件的方法:imgsrc=所有您需要做的是阅读领域的数据,并通过作为"身体"以及其他必要的参数的参数
奥姆・普拉卡什・潘特
评论会员:游客 时间:2012/02/07
PL检查以下线程的代码示例:{A}还可以看到下面的线程,如果你想使用的Gmail发送电子邮件:{A2的}]
Satheesh1546:嗨,

smtpClient.Host的肯定是"smtp.gmail.com"..
NBSP
干杯:amolpatil2243 | |你好,{ BR}
首先声明一个StringBuilder的变量。附加任何你想要发送在stringbuilder.make一个功能的sendmail与4个这样的参数

{C}然后得到所有正确的信息服务器,使用以下功能来发送邮件,只需复制并粘贴它会奏效。

public bool SendMailBySmtp(string from, string to, string subject, string body)

    {

        try

        {

            // Instantiate a new instance of MailMessage

            MailMessage ObjMailMessage = new MailMessage();

 

            // Set the sender address of the mail message

            ObjMailMessage.From = new MailAddress(from);

 

            // Set the recepient address of the mail message

            ObjMailMessage.To.Add(new MailAddress(to));

 

            // Set the subject of the mail message

            ObjMailMessage.Subject = subject;

            // Set the body of the mail message

            ObjMailMessage.Body = body;

 

            // Set the format of the mail message body as HTML

            ObjMailMessage.IsBodyHtml = true;

 

            // Set the priority of the mail message to normal

            ObjMailMessage.Priority = MailPriority.Normal;

 

            // Instantiate a new instance of SmtpClient           

            SmtpClient ObjSmtpClient = new SmtpClient(str_ServerDetails);

            ObjSmtpClient.Port = 25;

            

            //ObjSmtpClient.Credentials = CredentialCache.DefaultCredentials;



            if (!String.IsNullOrEmpty(str_UserName))

            {

                NetworkCredential ObjNC = new NetworkCredential(str_UserName, str_Password);

                ObjSmtpClient.Credentials = ObjNC;

            }

            else

            {

                ObjSmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;

            }

 

            // Send the mail message

            ObjSmtpClient.Send(ObjMailMessage);

            return true;

        }

        catch (SmtpException ex)

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

        catch (FormatException ex)

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

        catch (ArgumentException ex)

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

 

        catch (InvalidOperationException ex)

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

        catch (System.Security.SecurityException ex)

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

        catch (ConfigurationErrorsException ex)// IN CASE OF SHARED HOSTING

        {

            //HandelError ObjhandleError = new HandelError();

            //ObjhandleError.ManageError(ex.Message, "SendMailClass.sendMailbySMTP()");

            //return false;

        }

 

        return false;

    }

通过正确的参数功能
评论会员:游客 时间:2012/02/07
suman161288:首先添加两个命名空间{体C3}在Button_Click事件中使用此代码{的C4}请它解决此问题的帮助。感谢和问候苏曼