2017-01-30 14 views
0

ASP.netでSMTP経由で電子メールを送信しようとしていますが、電子メールは送信されず、エラーは発生しません。私のコード:ASP.netでSMTPを使用して電子メールを送信しない

   //create the mail message 
       System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); 
       //set the FROM address 
       mail.From = new MailAddress("[email protected]"); 
       //set the RECIPIENTS 
       mail.To.Add("[email protected]"); 
       //enter a SUBJECT 
       mail.Subject = "Set the subject of the mail here."; 
       //Enter the message BODY 
       mail.Body = "Enter text for the e-mail here."; 
       //set the mail server (default should be smtp.1and1.com) 
       SmtpClient smtp = new SmtpClient("smtp.1and1.com"); 
       //Enter your full e-mail address and password 
       smtp.Credentials = new NetworkCredential("[email protected]", "xxxxxxx"); 
       //send the message 
       smtp.Send(mail); 

そしてweb.configファイルで私のコードは、各パラメータの値を表示する

<system.net> 
    <mailSettings> 
     <smtp deliveryMethod="SpecifiedPickupDirectory"> 
     <specifiedPickupDirectory pickupDirectoryLocation="C:\Mail\" /> 
     </smtp> 
    </mailSettings> 
    <defaultProxy enabled="true" /> 
    </system.net> 
+0

あなたのSMTPポートが塞がれているか、資格情報が、私はのtry/catchを使用したが何も間違っては検出されません –

答えて

0

使用ブレークポイントです。コードにエラーがなくても、パラメータの値はnullまたは間違っている可能性があります。ブレークポイントの前にtry-catchを以下のように使用してください。

   try 
       { 
        // Your codes 
       } 
       catch (Exception ex) 
       { 
        throw new Exception(ex.Message.ToString()); 
       } 
+0

間違っている可能性があります。 – ajoy

関連する問題