2011-12-19 17 views
0

私はGodaddyを使ってメールを送るのにこの構文を正しく使うことに苦労してきました。どんな助けもありがとう。 web.configにコードを追加する必要がありますか?SendMail on Godaddy

System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage("[email protected]", "To", "subject ", "body "); 
         m.IsBodyHtml = true; 
         SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net"); 
         smtp.UseDefaultCredentials = true; 
         smtp.Send(m); 

エラーメッセージはこれです:私はこれを行う方法を見つけ出すことができたし、それが動作

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.201.192.101:467 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.201.192.101:467

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

+1

どのような問題があるようですか? –

+0

メールを送信しません。エラー画面が表示されます。私はcapad形式のgodaddyまたは何を購入する必要がありますか? – CsharpBeginner

+0

質問を編集し、エラーを投稿してください。 –

答えて

1

。コードは、同じ問題を抱えている他の人のためのコードです。

try 
     { 
      using (SmtpClient client = new SmtpClient("smtpout.secureserver.net")) 
      { 
       client.Credentials = new NetworkCredential("godaddyemail", "pw"); 


       //client.Credentials = CredentialCache.DefaultNetworkCredentials; 
       //client.DeliveryMethod = SmtpDeliveryMethod.Network; 

       string to = "send email to who"; 


       System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); 
       mail.From = new MailAddress("mygodaddyemail", "subject"); 
       mail.To.Add(to); 



       mail.Subject = "New member Alert"; 
       mail.Body = "New member "; 
       mail.IsBodyHtml = true; 

       client.Send(mail); 
       return "sent mail"; 
      } 
     } 
     catch (Exception ex) 
     { 
      // exception handling 
      return ex.ToString(); 
     }