2012-05-01 3 views
0

私はhostgatorでdotnetnukeモジュールを作成してメールを送信しようとしていますが、メールは機能しません。私に助言をお願いします。電子メールを送信するために私はhostgatorのメールで連絡フォームデータを送信しようとしています

protected void btnSubmit_Click(object sender, EventArgs e) 
    { 
     string Fname = txtFname.Text; 
     string Lname = txtLname.Text; 
     string Email = txtEmail.Text; 
     string Telephone = txtTelephone.Text; 
     string comments = txtComments.Text; 
     MailMessage newmail = new MailMessage(ConfigurationManager.AppSettings["FromEmailHelpForm"].ToString(), ConfigurationManager.AppSettings["ToEmailHelpForm"].ToString()); 
     newmail.Subject = "Contact Form Notification"; 
     newmail.IsBodyHtml = true; 
     newmail.Body = "<table><tr><td>First Name:<td><td>' " + Fname + " '</td><tr><tr><td>Last Name:<td><td>' " + Lname + " '</td><tr><tr><td>Primary Email Address: <td><td>' " + Email + " '</td><tr><tr><td>Telephone: <td><td>' " + Telephone + " '</td><tr><tr><td>Comments: <td><td>' " + comments + " '</td><tr></table>"; 

     SmtpClient mail = new SmtpClient("localhost"); 
     try 
     { 
      if (CaptchaControl1.IsValid) 
      { 
       mail.Send(newmail); 
       reset(); 
       pnlMessage.Visible = true; 
       pnlform.Visible = false; 
       lblError.Text = "Thankyou for submiting the form we will get you soon"; 
       lblError.ForeColor = System.Drawing.Color.Blue; 
      } 
      else 
      { 
       lblError.Text = "Invalid Security Code "; 
       lblError.ForeColor = System.Drawing.Color.Red; 
      } 

     } 
     catch (Exception err) 
     { 
      lblError.Text = "An error Occured -->"+err.Message; 
      lblError.ForeColor = System.Drawing.Color.Red; 
     } 
    } 

    public void reset() 
    { 
     txtFname.Text = ""; 
     txtLname.Text = ""; 
     txtTelephone.Text = ""; 
     txtEmail.Text = ""; 
     txtComments.Text = ""; 

    } 
} 

答えて

1

、あなたは本当SMTPサーバーを必要としています。 SMTPClientのHostプロパティを設定する必要があります。

既存のSMTPリレーサーバー(GMailなど)を使用することも、IISを仮想SMTPサーバーとして構成することもできます。

関連する問題