2017-01-30 1 views
0

Ich versuche, E-Mail über SMTP in ASP.net senden, aber E-Mail nicht senden und keinen Fehler geben. Mein Code:E-Mail nicht mit SMTP in ASP.net senden

   //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); 

Und mein Code in web.config ist

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

Ihr SMTP-Port ist möglicherweise blockiert oder die Anmeldeinformationen könnten falsch sein –

Antwort

0

Verwenden Haltepunkt jeder Parameterwert angezeigt werden soll. Auch wenn die Codes keinen Fehler enthalten, kann der Parameterwert null oder falsch sein. Vor dem Haltepunkt verwenden Sie try-catch wie folgt:

+0

Ich habe versucht/fangen, aber kein Fehler wird erkannt. – ajoy

Verwandte Themen