2011-04-12 21 views
0

我想發送郵件,所以我寫了一個方法在handler.ashx但我得到錯誤,因爲如何使用處理程序發送郵件?

「SendUsing」配置值無效。這是什麼意思,請幫助我

public bool Sendmail() { bool strResult = false; 嘗試 {

 email.Subject = " Registration"; 

     email.To = "[email protected]"; 
     email.From = "[email protected]"; 
     email.Cc = "[email protected]"; 
     email.Bcc = "[email protected]"; 
     email.BodyFormat = MailFormat.Html; 

     email.Body = "<html>" + 
         "<body>" + 
         "<b>Hi ravi</b>"+ 
         "</body>" + 
         "</html>"; 
     email.Priority = MailPriority.Normal; 


     SmtpMail.Send(email); 
     strResult = true; 
    } 
    catch (Exception ex) 
    { 
     //FTEHelper.SendEmail("[email protected]", "Ticket Upload Batch Error", 
     // ex.ToString()); 


     strResult = false; 

    } 


    return strResult; 





} 

回答

1

您應該指定一個SMTP服務器。

SmtpMail.SmtpServer = "yourservername"; 

此外,你應該考慮使用System.Net.Mail命名空間,而不是System.Web.Mail。 (如果你不是被迫使用.NET 1的話)。